Postfix Virtual Alias do-not-reply Forwarding to /dev/null
In situations with these e-mail addresses of type “do-not-reply” are sent, where the mailbox would have to be sweep at regular intervals, or if the mailbox does not exist at all, there is the easy way for incoming e-mails to use a postfix alias and virtual alias with forwarding to the null device – /dev/null.
The usual solution is by forwarding to /dev/null. In a local setup, this can be done in /etc/aliases.
1 2 |
do-not-reply: /dev/null |
However, when virtual postfix domains are used, it becomes a bit more expensive. For virtual domain users, e-mail cannot be forwarded to a file. It must go to a user or an email address, for which an alias user is added in /etc/aliases.
1 2 |
devnull: /dev/null |
After that, the new alias will be add to the aliases.db.
1 2 |
newaliases |
The alias points to a Virtual Domain Alias in /etc/postfix/virtual.
1 2 |
do-not-reply@foo.com devnull |
Note: By default, the Sendmail aliases located under /etc, for Postfix aliases is often copied under /etc/postfix, to make sure what is defined in /etc/postfix/main.cf is at alias_maps.
1 2 3 4 |
alias_maps = hash:/etc/aliases or alias_maps = hash:/etc/postfix/aliases |
After that run postmap.
1 2 |
postmap /etc/postfix/virtual |
and activates the Postfix change.
1 2 |
postfix reload |
How do you know if the change works!
The following command can be used to verify that the alias has been set up correctly.
1 2 |
postmap -q do-not-reply@foo.com /etc/postfix/virtual |
The following output should be made.
1 2 |
devnull |