Can I use Aliases on my Postfix email server to reroute mail to my admin email address?

1

I have an Ubuntu 16.04.2 server running Postfix 3.1.0, which I'm using as an email relay for another server running Cron jobs.

Various error emails, including bad address bounces, are being sent to www-data@mydomain.com, which doesn't have an email box. These messages are clogging up my postqueue with nowhere to go.

I've been trying to reroute these emails to me@myotherdomain.com with aliases, virtual or otherwise.

The problems I'm experiencing are:

  1. I'm not sure I the way I'm testing (using sendmail: sudo mail -s "test subject" www-data) is effective.
  2. I can't tell if my alias changes are being added correctly, despite using newaliases and postalias hash:/etc/aliases, as well as restarting the postfix service.
  3. I'm not sure this is actually even something that can be done with aliases, as opposed to header rewrites.

My alias file:

# See man 5 aliases for format
postmaster:     root

My virtual file:

www-data@mydomain.com me@myotherdomain.com

main.cf has alias_maps and alias_database set, but not virtual_alias_domains or virtual_alias_maps. That was going to be the next thing I tried, but if it's as I said earlier that my testing is no good, it won't make a difference.

What am I missing?

Will Washkuhn

Posted 2019-05-06T20:16:54.513

Reputation: 11

Answers

0

Okay, I've got this working now. Solution goes like this:

  1. Create /etc/postfix/virtual, and fill it with your virtual aliases, as I did in the original question.
  2. Run postmap /etc/postfix/virtual
  3. Populate virtual_alias_domains and virtual_alias_maps in main.cf
  4. Run postfix reload
  5. Test by running a command like mail -s "Test subject" www-data@mydomain.com <<< "Test body"

Then you should see the message show up in the rerouted mailbox.

Any time after that if I wanted to update my virtual file, I just reran steps 2 and 4 again.

The docs page that helped me figure it out: http://www.postfix.org/VIRTUAL_README.html#virtual_alias (See 'Mail forwarding domains' section)

Will Washkuhn

Posted 2019-05-06T20:16:54.513

Reputation: 11