I have set up my email server following the ISPMail tutorial with virtual users in postfix + dovecot + sieve. My problem is: the envelop
"variable" in sieve does not contain the original recipient.
I have a mail account, let's call it mail@example.org
and additional aliases set up for postfix which all deliver to the aforementioned address:
name@example.org -> mail@example.org
@domain.com -> mail@example.org
The latter being an catch-all address.
Postfix calls dovecot with the following config line in master.cfg
:
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d ${user}@${nexthop} -a ${recipient}
With sieve I want to put all mails received for the catch-all address into a specific folder. My sieve code looks like this:
if envelope :is :domain "To" "domain.com" {
fileinto "special-folder";
}
This sadly does not work. Digging further I found out that what's inside envelop
always is the final delivery address, i.e. mail@example.org
in this case. I found this using the following rule:
if envelope :matches "To" "*" {
fileinto "${1}";
}
And the sieve log telling me:
failed to store into mailbox 'mail@example.org': Mailbox doesn't exist: mail@example.org.
I'm already guessing that this has to be a problem somewhere between postfix and dovecot as the mail log tells me the following:
Aug 29 10:38:27 *** dovecot: lda(mail@example.org): sieve: msgid=<54003C01.1080704@***>: stored mail into mailbox 'INBOX'
Aug 29 10:38:27 *** dovecot: lda(mail@example.org): Error: sieve: execution of script /var/vmail/example.org/mail/dovecot.sieve failed, but implicit keep was successful (user logfile /var/vmail/example.org/mail/dovecot.sieve.log may reveal additional details)
Aug 29 10:38:27 *** postfix/pipe[12469]: A31A28006B: to=<mail@example.org>, orig_to=<test@domain.com>, relay=dovecot, delay=0.29, delays=0.18/0.01/0/0.1, dsn=2.0.0, status=sent (delivered via dovecot service)
Obviously postfix states the original recipient (test@domain.com) and the mailbox delivered to (mail@example.org) but somehow this information gets lost on the way to dovecot?!