Wednesday, March 27, 2013

My Postfix in Ubuntu

With postfix, you'll be able to receive emails from your localhost. Here's how I go about it.


sudo apt-get install postfix
For me, the option to "General type of configuration", I choose "Satellite system".


I'm going to use Google mail server here. You need to change the relayhost if you're not using gmail.
sudo vim /etc/postfix/
relayhost = []:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
Copy the certificate, it's optional but better we do it.
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
Set the credential to Google mail server.
sudo vim /etc/postfix/sasl_passwd
[]:587 [username][password]
sudo postmap /etc/postfix/sasl_passwd
Securing your password
sudo chmod 400 sasl_passwd.db
Finally, restart Postfix.
sudo service postfix restart


Install mailutils if you have not.
sudo apt-get install mailutils
Your choice of using mail or mailx.
echo "this is a test mail." | mail -s "test"
echo 'It works!' | mailx -s 'hello world'
Checking the log to see if anything goes wrong
tail -f /var/log/mail.log


Must issue a STARTTLS command first.
You're missing smtp_use_tls = yes in

No comments: