I’ve recently discovered something quite annoying with the use of Smtp relay (Mailjet).
When I setup a Mail forward for a user of my Yunohost instance, this mail forward will only partly work.
If an email is received from an email from the instance, it will be correctly forwarded
If an email is received from an external email domain, it will be received correctly but not forwarded
It seems that this is because the forwarded email from an external email domain is seen by the relay as a stranger domain, for which the relay has no authorization to send.
For those who would be interested, the best solution I could find so far :
Edit /etc/dovecot/dovecot.conf
Activate editheader sieve plugin by adding
plugin {
# Use editheader
sieve_extensions = +editheader
}
Relaunch Dovecot service
Use rainloop to create a new raw sieve filter
require ["copy","editheader","variables"];
# rule:[Redirect]
if true # for all emails - but you can change that part
{
# Match the From header field ...
if header :matches "From" "*" {
set "from" "${1}";
}
# Match the Subject field ...
if header :matches "Subject" "*" {
set "subject" "${1}";
}
# Delete the Subject
deleteheader :contains "Subject";
# Recreate the subject and add the sender info
addheader :last "Subject" "[Redirect from ${from}] ${subject}";
# Make sure that external email will be able to reply to the right person
addheader "Reply-To" "${from}";
# Delete the sender
deleteheader :contains "From";
# Replace the sender by the Yunohost receiver email
# This will trick the SMTP relay provider
addheader "From" "youremail@yourinstance.fr";
# Forward a copy to external email
redirect :copy "email@external.fr";
}
This works very well. Only compromise is that the external email will receive the email as being sent from youremail@yourinstance.fr instead of the sender.
In my opinion a small compromise that makes available the safety and good receivability of using an external SMTP relay !