Skip to Content

Postfix - automatically drop outbound mail

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: :
* discard:

Then run:

postmap /etc/postfix/transport

At end, add these to /etc/postfix/

transport_maps = hash:/etc/postfix/transport

Reload postfix:

postfix reload

Test if it works:

echo test | mail -s test [email protected]

You should see in logs that message was dropped:

Mar 18 21:14:28 devmx1 postfix/cleanup[29968]: 1E77654391: [email protected]>
Mar 18 21:14:28 devmx1 postfix/qmgr[28282]: 1E77654391: from=<[email protected]>, size=431, nrcpt=1 (queue active)
Mar 18 21:14:28 devmx1 postfix/discard[29970]: 1E77654391: to=<[email protected]>, relay=none, delay=0.1, delays=0.09/0.01/0/0, dsn=2.0.0, status=sent (
Mar 18 21:14:28 devmx1 postfix/qmgr[28282]: 1E77654391: removed
comments powered by Disqus