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 root@comcast.net (they don’t appreciate getting my SPAM):
root: myusername@localhostI 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-onlyI added the following to /etc/postfix/sasl_passwd:
smtp.comcast.net MyUsername:MyPasswordI added the following to /etc/postfix/sender_canonical:
jaredrob MyUsername@comcast.netI 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/aliasesNext, 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
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.
