Forward Postfix alias to dev-null

5
(3)

Postfix Virtual Alias do-not-reply Forwarding to /dev/null

Where “Do-Not-Reply” type e-mail addresses are in use, the mailbox should be cleaned regularly, but perhaps the mailbox should not exist. Here is a simply way for incoming e-mails to use postfix virtual alias with forwarding to null device.

The usual solution is by forwarding to /dev/null. In a local setup, this can be done in /etc/aliases.

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.

devnull: /dev/null

After that, the new alias will be add to the aliases.db.

$ newaliases

The alias points to a Virtual Domain Alias in /etc/postfix/virtual.

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.

alias_maps = hash:/etc/aliases
or
alias_maps = hash:/etc/postfix/aliases

After that run postmap.

$ postmap /etc/postfix/virtual

and reload Postfix to activate the changes.

$ 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.

$ postmap -q do-not-reply@foo.com /etc/postfix/virtual

The following output should be made.

devnull

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *