Wednesday, December 22, 2010

HOWTO : Send Mail to GMail by Postfix on Ubuntu Server 10.10

You cannot send any mail to GMail from you mail server, unless you set GMail server as your SMTP server.

Step 0 :

Install the Ubuntu Server 10.10 and select Mail Server when install.

Step 1 :

sudo nano /etc/postfix/transport

Append the following line.

*     smtp:[smtp.gmail.com]:587

Step 2 :

sudo nano /etc/postfix/sasl/sasl_passwd

Append the following line.

[smtp.gmail.com]:587     samiux@gmail.com:password

Step 3 :

sudo nano /etc/postfix/main.cf

Add or make the change of the following lines.

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
mynetworks = 192.168.0.0/24 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128


Step 4 :

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Step 5 :

sudo postmap /etc/postfix/transport
sudo postmap /etc/postfix/sasl/sasl_passwd


Step 6 :

sudo /etc/init.d/postfix restart

That's all! See you.