From 7287e63341e31b4abb0ce407eada9507cfecb366 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 17 Jul 2026 15:18:49 +0200 Subject: [PATCH] Added placeholders from reply-to, CC, and BCC --- FAQ.md | 6 +++++ .../java/eu/faircode/email/MessageHelper.java | 24 ++++++++++++++++--- index.html | 8 ++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/FAQ.md b/FAQ.md index aa6011cca0..3e53ecfc45 100644 --- a/FAQ.md +++ b/FAQ.md @@ -928,6 +928,12 @@ if your provider allows this. Considering the email address test@example.org you * "*Some name, username*" will result in the email address "*Some name, <username@example.org>*" (since version 1.2032) You can configure a default CC, BCC and/or reply-to address in the advanced identity settings. +Since version 1.2326 you can use the following placeholders in these default addressess: + +* $from$: the full 'from' address +* $user$: the username of the 'from' address +* $domain$: the domain name of the 'from' address +* $extra$: the extra as explained above FairEmail will automatically update the passwords of related identities when you update the password of the associated account or a related identity. diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index b9bcc18a6e..b4d81ae25b 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -549,15 +549,15 @@ public class MessageHelper { (message.dsn == null || EntityMessage.DSN_NONE.equals(message.dsn))) { // Add reply to if (identity.replyto != null) - imessage.setReplyTo(convertAddress(InternetAddress.parse(identity.replyto), identity)); + imessage.setReplyTo(convertAddress(InternetAddress.parse(replacePlaceholders(identity.replyto, message, identity)), identity)); // Add extra cc if (identity.cc != null) - addAddress(identity.cc, Message.RecipientType.CC, imessage, identity); + addAddress(replacePlaceholders(identity.cc, message, identity), Message.RecipientType.CC, imessage, identity); // Add extra bcc if (identity.bcc != null) - addAddress(identity.bcc, Message.RecipientType.BCC, imessage, identity); + addAddress(replacePlaceholders(identity.bcc, message, identity), Message.RecipientType.BCC, imessage, identity); } // Delivery/read request @@ -858,6 +858,24 @@ public class MessageHelper { return new InternetAddress(email, name, StandardCharsets.UTF_8.name()); } + static String replacePlaceholders(String address, EntityMessage message, EntityIdentity identity) throws UnsupportedEncodingException { + if (!TextUtils.isEmpty(address) && + (address.contains("$from$")) || address.contains("$user$") || address.contains("$domain$") || address.contains("$extra$")) { + Address from = getFrom(message, identity); + if (from instanceof InternetAddress) { + String email = ((InternetAddress) from).getAddress(); + String user = UriHelper.getEmailUser(email); + String domain = UriHelper.getEmailDomain(email); + address = address + .replace("$from$", email) + .replace("$user$", user) + .replace("$domain$", domain) + .replace("$extra$", message.extra == null ? "" : message.extra); + } + } + return address; + } + static String limitReferences(String ref) { final int maxlen = MAX_HEADER_LENGTH - "References: ".length(); diff --git a/index.html b/index.html index 962d7e0f9f..a3a7fc7798 100644 --- a/index.html +++ b/index.html @@ -708,7 +708,13 @@ or by installing the GitHub version of the app (as an update) and enabling insec
  • @extra” will result in the email address “test@extra.example.org
  • Some name, username” will result in the email address “Some name, <username@example.org>” (since version 1.2032)
  • -

    You can configure a default CC, BCC and/or reply-to address in the advanced identity settings.

    +

    You can configure a default CC, BCC and/or reply-to address in the advanced identity settings. Since version 1.2326 you can use the following placeholders in these default addressess:

    +

    FairEmail will automatically update the passwords of related identities when you update the password of the associated account or a related identity.

    See this FAQ on editing the username of email addresses.