My email provider has support for the sieve language (RFC 5228) in advanced mode email filters, but states they "cannot provide additional support on this subject". I'd want to use sieve to improve my current email redirection strategy.
What would be a minimal sieve script such that when an email is somewhat sent to [email protected]
, which is an alias of my main email account [email protected]
, it's made a copy to [email protected]
(preferably: except if it's detectable from the headers that [email protected]
is already an addressee).
I can do almost that with their web-based (non-sieve) rule maker, by testing if the To:
or Cc:
field is (or contains) [email protected]
. However it's not robust. In particular it fails if the email is sent Bcc: [email protected]
(which is not among the fields I can specify) or via a redirection to [email protected]
(and I don't even know which field I could test for that).
Also, if the email is sent To: [email protected]
and Cc: [email protected]
, I'm afraid the later would receive the email twice.
Update: as suggested in a helpful comment, experiments shows that in what I get thru IMAP in the inbox for [email protected]
for something sent to it's alias as Bcc: [email protected]
(or even Bcc: [email protected]
redirecting to [email protected]
), something has helpfully added (on the second line)
Delivered-To: [email protected]
So, assuming that a sieve script runs after that header is generated (I have no idea if that's the case), it may be that I need a minimal sieve script such that when Delivered-To:
is [email protected]
the email gets copied to [email protected]
(preferably: only when neither To:
nor Cc:
includes [email protected]
)
I'm a seasoned programmer and postmaster, thus I see possible pitfalls in "includes". It should not be in the sense of string inclusion, should at least be case insensitive, and apply only to the email address without name. I'd like this (my first sieve script) to be as canonical as possible.
X-Original-To:
header with the original e-mail recipient that was used in the SMTP (envelope)RCPT TO
command when delivering the e-mail message to the SMTP server. That is the original recipient before expanding any local aliases and would be[email protected]
even when that address is on theBCC:
list and not included in the addresses of the message headers. My mailserver sets a second headerDelivered-To:
that is the recipient after expanding all local aliases and forwards.X-Original-To: [email protected]
Delivered-To: [email protected]