Sunday, June 21, 2015

Configure Postfix to Use Gmail on Ubuntu

If you want to use a Gmail account as a free SMTP server on your Ubuntu-Linux server, you will find this article useful. This guide is tested with Ubuntu 14.04. If you face any issue, feel free to use comments-section below.

Step 1 -First, install all necessary packages

sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules 

If you do not have postfix installed before, postfix configuration wizard will ask you some questions. Just select your server as Internet Site and for FQDN use something like mail.example.com

Step -2 Then open your postfix config file:

vim /etc/postfix/main.cf

add following lines to it:

relayhost = [smtp.gmail.com]:587 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 smtp_use_tls = yes    


You might have noticed that we haven’t specified our Gmail username and password in above lines. They will go into a different file. Open/Create

vim /etc/postfix/sasl_passwd

And add following line:

[smtp.gmail.com]:587 USERNAME@gmail.com:PASSWORD

If you want to use your Google App’s domain, please replace @gmail.com with your @domain.com

Step -3 Fix permission and update postfix config to use sasl_passwd file


sudo chmod 400 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwd


Step -4 validate certificates to avoid running into error. Just run following command
  
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
Step -5

Finally, reload postfix config for changes to take effect:

sudo /etc/init.d/postfix reload

Testing -

If you have configured everything correctly, following command should generate a test mail from your server to your mailbox.


echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com     


Keep Sharing, njoy learning   

Share This!


4 comments:


  1. windows 8.1 product key buy , free window 7 ulmtimate key , downloadeaza gratis windows vista home premium , windows 10 key , buy office pro 2013 key , onekey activation office 2013 , activation key for window 7 ultimate 32 bit , win 7key , s9pRN1

    ReplyDelete
  2. windows 7 ultimate sp1 keys , windows 7 starter to home premium upgrade with activation key , windows 10 activation clean install , windows anytime upgrade key for windows 7 home premium to ultimate , genuine windows 7 starter upgrade product key , windows 10 professional key , windows 7 starter edition product key free , windows 10 product key 10240 , wL7uBX

    office 2013 product key

    windows 10 enterprise key

    vmware workstation 11 to buy

    ReplyDelete
  3. Students Lab... Keep Sharing Enjoy Learning : Configure Postfix To Use Gmail On Ubuntu >>>>> Download Now

    >>>>> Download Full

    Students Lab... Keep Sharing Enjoy Learning : Configure Postfix To Use Gmail On Ubuntu >>>>> Download LINK

    >>>>> Download Now

    Students Lab... Keep Sharing Enjoy Learning : Configure Postfix To Use Gmail On Ubuntu >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete