I have development server with postfix - I wanted to allow outbound traffic to one domain but cut off all the rest. I definitely do not want that test mail or any debug info goes to service users.
I have to add something like that to /etc/postfix/transport
:
allowed.domain.com :
* discard:
Then run:
postmap /etc/postfix/transport
At end, add these to /etc/postfix/main.cf
:
transport_maps = hash:/etc/postfix/transport
Reload postfix:
postfix reload
Test if it works:
echo test | mail -s test whatever@whatever.com
You should see in logs that message was dropped:
Mar 18 21:14:28 devmx1 postfix/cleanup[29968]: 1E77654391: message-id=20140318211428.1E77280521@domain.com>
Mar 18 21:14:28 devmx1 postfix/qmgr[28282]: 1E77654391: from=<root@domain.com>, size=431, nrcpt=1 (queue active)
Mar 18 21:14:28 devmx1 postfix/discard[29970]: 1E77654391: to=<whatever@whatever.com>, relay=none, delay=0.1, delays=0.09/0.01/0/0, dsn=2.0.0, status=sent (whatever.com)
Mar 18 21:14:28 devmx1 postfix/qmgr[28282]: 1E77654391: removed