Monday, June 17, 2013

How to configure Postfix to send mail via Google Apps

In this tutorial, we’ll configure Postfix to send an email through Google’s SMTP on Ubuntu 12.04 LTS Server for Google Apps. We can use the exact same setup for Gmail account also:

google-apps

Install Postfix and command line mail utility using the following command:
sudo apt-get install postfix mailutils

1

Backup the default configuration file for postfix:
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.bk

1a

Edit the /etc/postfix/main.cf file:
sudo nano /etc/postfix/main.cf

2

Delete everything from main.cf file and add this:
smtp_sasl_security_options = noanonymous
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/googleapps/password

3

Create a directory googleapps under /etc/postfix:
sudo mkdir /etc/postfix/googleapps

4

Move to the /etc/postfix/googleapps directory:
cd /etc/postfix/googleapps/

5

Create a file named password inside /etc/postfix/googleapps directory:
sudo nano password

6

Add the following contents to the password file:
[smtp.gmail.com]:587 arbab.nazar@rbgeek.com:password

7

Note: arbab.nazar@rbgeek.com is a Google apps mail address of mine with false password, you can use your original Google apps email address and password here.

Change the permission on password file:
sudo chmod 600 password

8

Transform the password file into a hashed table:
sudo postmap password

9

Copy CA root certificates to postfix directory:
sudo cp /etc/ssl/certs/ca-certificates.crt /etc/postfix/cacert.pem

10

Restart the postfix service:
sudo /etc/init.d/postfix restart

11

Test the postfix server by sending an email to another account:
echo "Testing" | mail -s "Email from tendo" arbabnazar@ymail.com

12

Check the destination email account:

13

Hope this will help you!

No comments:

Post a Comment