Added placeholders from reply-to, CC, and BCC

master
M66B 2 weeks ago
parent 86b78adf50
commit 7287e63341

@ -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.

@ -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();

@ -708,7 +708,13 @@ or by installing the GitHub version of the app (as an update) and enabling insec
<li><em><span class="citation" data-cites="extra">@extra</span></em>” will result in the email address “<em>test@extra.example.org</em></li>
<li><em>Some name, username</em>” will result in the email address “<em>Some name, &lt;username@example.org&gt;</em>” (since version 1.2032)</li>
</ul>
<p>You can configure a default CC, BCC and/or reply-to address in the advanced identity settings.</p>
<p>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:</p>
<ul>
<li><span class="math inline"><em>f</em><em>r</em><em>o</em><em>m</em></span>: the full from address</li>
<li><span class="math inline"><em>u</em><em>s</em><em>e</em><em>r</em></span>: the username of the from address</li>
<li><span class="math inline"><em>d</em><em>o</em><em>m</em><em>a</em><em>i</em><em>n</em></span>: the domain name of the from address</li>
<li><span class="math inline"><em>e</em><em>x</em><em>t</em><em>r</em><em>a</em></span>: the extra as explained above</li>
</ul>
<p>FairEmail will automatically update the passwords of related identities when you update the password of the associated account or a related identity.</p>
<p>See <a href="#faq33">this FAQ</a> on editing the username of email addresses.</p>
<p><br /></p>

Loading…
Cancel
Save