After having had Ubuntu 12.04 installed for months, I finally moved my old Fedora services over to it, including Postfix. Here’s how I configured it.
I configured /etc/aliases so that local email destined for ‘root’ (including regularly scheduled system cron jobs) is delivered to my local account, instead of being sent to email@example.com (they don’t appreciate getting my SPAM):
I added the following to /etc/postfix/main.cf. Notice that I appended a “.NOT” to the relayhost. I did this initially so that I could send test email messages, and make sure message delivery was correct, before allowing email to go to my ISP. More on this later.
alias\_maps = hash:/etc/aliases alias\_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = $myhostname, localhost.$mydomain, localhost, robinson-lin relayhost = [smtp.comcast.net.NOT]:587 smtp\_sasl\_auth\_enable = yes smtp\_sasl\_password\_maps = hash:/etc/postfix/sasl\_passwd smtp\_sasl\_security\_options = sender\_canonical\_maps = hash:/etc/postfix/sender\_canonical mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox\_command = /usr/bin/procmail -a "$EXTENSION" mailbox\_size\_limit = 0 recipient\_delimiter = + inet\_interfaces = loopback-only
I added the following to /etc/postfix/sasl\_passwd:
I added the following to /etc/postfix/sender\_canonical:
I ran the following commands:
chmod o-r /etc/postfix/sasl_passwd postfix check postmap /etc/postfix/sasl\_passwd postmap /etc/postfix/sender\_canonical postalias /etc/aliases
Next, I tested my email configuration by sending test email messages (using ‘mutt’ or ‘mail’)…
- From my local linux account to my local linux account, to make sure local delivery worked and didn’t get sent to my ISP.
- From the local ‘root’ account to my local linux account.
- From the local ‘root’ account to my local ‘root’ account, to make sure it was forwarded to my local user account (remember /etc/aliases?)
- From my local account to an external account (gmail, etc.)
- I didn’t expect it to be delivered at this point. Remember the “.NOT” I added to my relay host? This way, I was able to see where outbound email was destined using “mailq”. This saved me grief because I found misconfigurations that would have lost the email. I used ‘postsuper -d ALL’ to delete all test messages from the queue.
- When I knew delivery was destined for the correct machines, I removed the “.NOT” from main.cf, and ran “service postfix reload” (as root).
- Next, I sent email to an external email address, and made sure it was delivered
Then I configured and ran ‘fetchmail’ briefly (hitting CTRL-C after a few were downloaded), and made sure messages were delivered to my local account properly. I’ve been pleased using Ubuntu with postfix, fetchmail and procmail and archivemail. I often log in remotely using SSH and use mutt to read my email. I also use Google Mail. I’ve set up rules to forward some email to my ISP account, which get downloaded using fetchmal via cron job.
Why do I bother saving my email to my local machine? I like redundancy and backups, I like the speed of using a command line email reader, and I have ten years of email archived on my local machine. It’s been very useful to be able to search through that email for old software license keys, website passwords, email addresses and such.