I have a server that is meant to deliver emails from PHP but not receive any emails. My domain MX records point to a different mail service and I have Postfix configured to not handle any FQDN emails. I'd like to send any local emails (postmaster errors, cronjob notices, etc.) to a single external email address me@external.com.
I've found a couple different questions on here that attempt to solve this (here and here most notably), but they seem to redirect all outbound emails as well, for example someone@gmail.com and someone@yahoo.com get delivered to me@external.com too.
One solution that does seem to work would be writing out virtual aliases for @localhost, @localhost.localdomain, and @cookweb1 separately to me@external.com, but surely there's a more elegant, generic solution? Here is the relevant part of my /etc/postfix/main.cf (erroneously forwards ALL mail to me@external.com):
myhostname = cookweb1
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = cookweb1, localhost.localdomain, localhost
relayhost =
mynetworks = loopback-only
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp
/etc/postfix/virtual is empty. Here is /etc/postfix/virtual-regexp (both have postmaps generated):
/.+@.+/ me@external.com