Add format_flowed option for composing e-mail

When format_flowed=true, generated text/plain attachments include the
format=flowed MIME parameter.

format_flowed is set to true by default.
jmap
Manos Pitsidianakis 2019-11-17 13:27:22 +02:00
parent 953c3aa9d0
commit 094ce7ee69
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 22 additions and 2 deletions

View File

@ -227,6 +227,10 @@ command to launch editor. Can have arguments. Draft filename is given as the las
(optional) embed editor within meli (optional) embed editor within meli
.\" default value .\" default value
.Pq Em false .Pq Em false
.It Cm format_flowed Ar boolean
(optional) set format=flowed [RFC367] in text/plain attachments.
.\" default value
.Pq Em true
.El .El
.Sh SHORTCUTS .Sh SHORTCUTS
Shortcuts can take the following values: Shortcuts can take the following values:

View File

@ -1202,6 +1202,7 @@ pub fn send_draft(
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
let mut failure = true; let mut failure = true;
let settings = &context.settings; let settings = &context.settings;
let format_flowed = settings.composing.format_flowed;
let parts = split_command!(settings.composing.mailer_cmd); let parts = split_command!(settings.composing.mailer_cmd);
let (cmd, args) = (parts[0], &parts[1..]); let (cmd, args) = (parts[0], &parts[1..]);
let mut msmtp = Command::new(cmd) let mut msmtp = Command::new(cmd)
@ -1213,8 +1214,18 @@ pub fn send_draft(
{ {
let stdin = msmtp.stdin.as_mut().expect("failed to open stdin"); let stdin = msmtp.stdin.as_mut().expect("failed to open stdin");
if sign_mail.is_true() { if sign_mail.is_true() {
let mut content_type = ContentType::default();
if format_flowed {
if let ContentType::Text {
ref mut parameters, ..
} = content_type
{
parameters.push((b"format".to_vec(), b"flowed".to_vec()));
}
}
let mut body: AttachmentBuilder = Attachment::new( let mut body: AttachmentBuilder = Attachment::new(
Default::default(), content_type,
Default::default(), Default::default(),
std::mem::replace(&mut draft.body, String::new()).into_bytes(), std::mem::replace(&mut draft.body, String::new()).into_bytes(),
) )

View File

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with meli. If not, see <http://www.gnu.org/licenses/>. * along with meli. If not, see <http://www.gnu.org/licenses/>.
*/ */
use super::default_vals::{false_val, none}; use super::default_vals::{false_val, none, true_val};
/// Settings for writing and sending new e-mail /// Settings for writing and sending new e-mail
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
@ -32,6 +32,10 @@ pub struct ComposingSettings {
/// Embed editor (for terminal interfaces) instead of forking and waiting. /// Embed editor (for terminal interfaces) instead of forking and waiting.
#[serde(default = "false_val")] #[serde(default = "false_val")]
pub embed: bool, pub embed: bool,
/// Set "format=flowed" in plain text attachments.
/// Default: true
#[serde(default = "true_val")]
pub format_flowed: bool,
} }
impl Default for ComposingSettings { impl Default for ComposingSettings {
@ -40,6 +44,7 @@ impl Default for ComposingSettings {
mailer_cmd: String::new(), mailer_cmd: String::new(),
editor_cmd: None, editor_cmd: None,
embed: false, embed: false,
format_flowed: true,
} }
} }
} }