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!

Advertisements
Posted in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

ABOUT AUTHOR
Rodel Sales is a freelance I.T Professional . Start blogging on May 2013 to share my technical skills to other I.T professionals, and collect imperative guide from the internet world.
Blog Archieve
May 2013
M T W T F S S
    Jun »
 12345
6789101112
13141516171819
20212223242526
2728293031  
%d bloggers like this: