diff --git a/docs/meli.conf.5 b/docs/meli.conf.5 index 9be3eec2..d6220aa1 100644 --- a/docs/meli.conf.5 +++ b/docs/meli.conf.5 @@ -138,6 +138,9 @@ The glob wildcard can be used to match every mailbox name and path. .It Ic identity Ar String Your e-mail address that is inserted in the From: headers of outgoing mail. +.It Ic extra_identities Ar [String,] +Extra e-mail address identities. +When replying to an e-mail addressed to one of these identities, the From: header will be adjusted to its value instead of the default identity. .El .TS allbox tab(:); diff --git a/melib/src/conf.rs b/melib/src/conf.rs index 001e1c12..6168e60a 100644 --- a/melib/src/conf.rs +++ b/melib/src/conf.rs @@ -30,6 +30,7 @@ pub struct AccountSettings { pub root_mailbox: String, pub format: String, pub identity: String, + pub extra_identities: Vec, pub read_only: bool, pub display_name: Option, pub subscribed_mailboxes: Vec, diff --git a/src/components/mail/compose.rs b/src/components/mail/compose.rs index 0dcc2a58..b9b1cde5 100644 --- a/src/components/mail/compose.rs +++ b/src/components/mail/compose.rs @@ -249,6 +249,21 @@ impl Composer { ret.draft .set_header("In-Reply-To", envelope.message_id_display().into()); + if let Some(reply_to) = envelope + .other_headers() + .get("To") + .and_then(|v| v.as_str().try_into().ok()) + { + let to: &str = reply_to; + let extra_identities = &account.settings.account.extra_identities; + if let Some(extra) = extra_identities + .iter() + .find(|extra| to.contains(extra.as_str())) + { + ret.draft.set_header("From", extra.into()); + } + } + // "Mail-Followup-To/(To+Cc+(Mail-Reply-To/Reply-To/From)) for follow-up, // Mail-Reply-To/Reply-To/From for reply-to-author." // source: https://cr.yp.to/proto/replyto.html diff --git a/src/conf.rs b/src/conf.rs index b92cf79b..1a611a69 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -155,6 +155,8 @@ pub struct FileAccount { root_mailbox: String, format: String, identity: String, + #[serde(default)] + extra_identities: Vec, #[serde(default = "none")] display_name: Option, @@ -254,6 +256,7 @@ impl From for AccountConf { root_mailbox, format, identity, + extra_identities: x.extra_identities.clone(), read_only: x.read_only, display_name, subscribed_mailboxes: x.subscribed_mailboxes.clone(), @@ -444,6 +447,7 @@ This is required so that you don't accidentally start meli and find out later th root_mailbox, format, identity, + extra_identities, read_only, display_name, subscribed_mailboxes, @@ -461,6 +465,7 @@ This is required so that you don't accidentally start meli and find out later th root_mailbox, format: format.clone(), identity, + extra_identities, read_only, display_name, subscribed_mailboxes,