Question

Currently I am filtering incoming mails by a .forward in the following way:

if $header_to: matches "(office|info)@domain.com" then
    save Maildir/.office/
endif
if $header_to: matches "whatever@domain.com" then
    save Maildir/.whatever/
endif

So I have a mail account, which receives mails for different addresses. Basically I want them to land in different subdirs based on the address the mail was sent to.

This works for mails where the recipient is in the to-header, but does not work if the recipient was in the bcc.

When a mail is received which was sent with the bcc-header, only the envelope-to-header matches the real address the mail is delivered to and it is mentioned in a Received-header

Envelope-to: office@domain.com

Received: from mail.other.domain ([1.1.1.1])
    by mail.domain.com with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
    (Exim 4.71)
    (envelope-from <sender@other.domain>)
    id 1RO5xc-0001TF-Qj
    for office@domain.com; Wed, 09 Nov 2011 12:04:57 +0100
...
To: can_be_anything@whatever.com

I already tried:

if $header_envelope-to: matches ...

but this does not work, mails are not filtered at all even when sent with To-header (looks like the Envelope-To-header is not available in forward-files). Should I try to parse the (multiple) Received-headers?

How can I move mails into a subdir of the recipient based on the real recipient address?

Was it helpful?

Solution

looks like I finally found the answer.

if $original_local_part matches "office|info" then
    save Maildir/.office/
endif

This checks only the local_part, but afaik could be extended to use the domain, too, with $original_domain (see the doc)

OTHER TIPS

The variable $recipients contains all (to, cc and bcc) recipients. Have you tried it?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top