I'm using Postfix and Dovecot LMTP on my server. My question is how do I create a silently discarding recipient address and respond auto reply? Also I want to learn Postfix and Dovecot execution control flow.
This is part of my Postfix main.cf
:
alias_maps = hash:/etc/aliases
# Virtual domains
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_minimum_uid = 115
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = mysql:/etc/postfix/mysql/mailbox.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/domains.cf
virtual_alias_maps = mysql:/etc/postfix/mysql/aliases.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
In my /etc/aliases
:
devnull: /dev/null
In my humble understanding Postfix handles recipient address exists or not right? If recipient address was existed then transport to Dovecot LMTP to handle local delivery. Is it possible to conditional transport in Postfix? For example I want to create a test mail address such as [email protected]
. Which account is aliased to devnull
. My goal is recipient [email protected]
silently discarded incoming mail and auto reply PONG message to sender for testing purpose. If recipient address wasn't [email protected]
then transport to Dovecot-lmtp. I tried to use Dovecot Sieve filter plugin with vacation extension to handle auto reply. But in my system's mail.log:
# replaced actual domain name with DOMAIN
postfix/lmtp[13532]: 62EBD333697: to=<devnull@DOMAIN>, orig_to=<ping@DOMAIN>, relay=DOMAIN[private/dovecot-lmtp], delay=538, delays=538/0.02/0.01/0.44, dsn=5.1.1, status=bounced (host DOMAIN[private/dovecot-lmtp] said:
550 5.1.1 <devnull@DOMAIN> User doesn't exist: devnull@DOMAIN (in reply to RCPT TO command))
So, I guess Dovecot Sieve filter plugin doens't work with account which doesn't exist. Is it possible to execute Sieve script before checking user's mailbox? If so I don't even need to use devnull
blackhole alias. I can do that in my sieve script something like this:
if address :matches "To" "ping@*" {
vacation
:seconds 1
"PONG";
discard;
}
UPDATED:
I created a user named ping
in my database and I got a response mail in my GMail account. But it wasn't really a reply mail. It was a new mail in my inbox. Then I tried to manually reply using Apple mail GUI software. It works as expected. Then I go to gmail and press on menu show original
.
From Apple Mail's message-id
domain part was correct virtual domain of sender.
But from Dovecot/Sieve's message-id
domain part was my server's hostname
.
I don't know why it happens. But my guess is maybe it's because domain name was changed? In working example from Apple Mail software it was correct virtual domain of sender. But from sieve auto-reply it was changed my server's real hostname.
Another Postfix log from /var/log/mail.log
postfix/cleanup[1329]: EE83F333699: message-id=<dovecot-sieve-1623257247-953496-0@HOSTNAME>
PS: I have only few days experience with Postfix, Dovecot and few hours experience with sieve script. I'm so newbie. I hope my question and goal was clear enough. Ask me anything if you need more information.