Make Postfix deliver all emails locally – no-external emails allowed

Install postfix, mailutils and mutt.

apt-get install postfix
apt-get install mailutils
apt-get install mutt

Stop Postfix

/etc/init.d/postfix stop

Create a Postfix "transport" file to redirect all emails :

/etc/postfix/transport

localhost:root
www.YOURDOMAIN.com:root
* local:root

This routes all emails from all domains (*) to the root user.

Compile(map) the /etc/postfix/transport file. This transforms it into "transport.db" a readable database for Postfix.

postmap /etc/postfix/transport

Note: ignore whitespace warning messages if you check /etc/postfix you'll see "transport.db" is created.

Restart postfix

/etc/init.d/postfix restart

DONE!

All external email will now be diverted to your local users mail and by default the "root" user account.
eg. info@someplace.com will get sent to the "info" user if present, if not they'll be delivered to root.
Local mails will still be delivered to local users, as usual.

If you wanted a specific email address routed correctly, you can do this by adding a line to the "transport" file.

info@startnet.co.uk smtp

this routes "info@startnet.co.uk" to usual smtp method. Don't forget to re-do post /etc/postfix/transport!

Just login or su as root and use "mutt" to read any emails.

Leave a Reply