Difference between revisions of "Gmail As Relay On Ubuntu"

From Amahi Wiki
Jump to: navigation, search
(Created page with " sudo apt-get postfix mailutils Select internet from the pop up and then OK. postconf -e 'relayhost=gmail-smtp-in.l.google.com' postconf -e 'smtp_sasl_auth_enable=yes' postcon...")
 
Line 1: Line 1:
 +
tags: mail gmail ubuntu postfix relay
  
 +
{{MessageBox|
 +
backgroundcolor = red|
 +
image =Warning.png|
 +
heading =WARNING|
 +
message = This is recommended only for advanced users, proceed with caution.}}
 +
This can be used to send mails from your HDA and to receive system emails.<br>
 +
To receive emails meant for the root user, you have to [[Forward_System_Emails|Forward System Emails]] after finishing this tutorial.<br>
  
sudo apt-get postfix mailutils
+
*Install postfix and remove sendmail: <br>
 +
{{Code|sudo apt-get -y postfix mailutils
 +
sudo apt-get -y remove sendmail}}
  
Select internet from the pop up and then OK.
+
'''NOTE:'''  During install of postfix, a popup box may display.  If it does, select '''''Internet''''' and then '''OK'''.
  
postconf -e 'relayhost=gmail-smtp-in.l.google.com'
+
*Execute the following to update /etc/postfix/main.cf:
postconf -e 'smtp_sasl_auth_enable=yes'
+
{{Code|sudo postconf -e 'relayhost<nowiki>=</nowiki>gmail-smtp-in.l.google.com'
postconf -e 'smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd'
+
sudo postconf -e 'smtp_sasl_auth_enable<nowiki>=</nowiki>yes'
postconf -e 'smtp_sasl_security_options='
+
sudo postconf -e 'smtp_sasl_password_maps<nowiki>=</nowiki>hash:/etc/postfix/sasl_passwd'
 +
sudo postconf -e 'smtp_sasl_security_options<nowiki>=</nowiki>'}}
  
echo "gmail-smtp-in.l.google.com   sahabcse@gmail.com:XXXXXX" > /etc/postfix/sasl_passwd
+
*Create '''/etc/postfix/sasl_passwd''' file with your Gmail login credentials that looks like below:
 +
{{Text|Text=gmail-smtp-in.l.google.com user@gmail.com:password}}
  
chown root:root /etc/postfix/sasl_passwd
+
Obviously, you need to change ''user'' to your username and ''password'' to your gmail password. <br>
chmod 600 /etc/postfix/sasl_passwd
 
  
postmap /etc/postfix/sasl_passwd
+
*Create the password  database: <br>
 +
{{Code|sudo postmap hash:/etc/postfix/sasl_passwd}}
  
/etc/init.d/postfix restart
+
*Protect the files with your Gmail login data:
 +
{{Code|sudo chown root:root /etc/postfix/sasl_passwd
 +
sudo chmod 600 /etc/postfix/sasl_passwd}}
  
echo "This is Content" | sudo mail -s "This is subject" user@home.com
+
*Restart Postfix:
 +
{{Code|sudo /etc/init.d/postfix restart}}
  
tail -f /var/log/mail.log
+
*Now try sending a mail, it should reach your Gmail account:
 +
{{Code|echo "This is Content" <nowiki>|</nowiki> sudo mail -s "This is subject" user@gmail.com}}
  
 +
*Check the mail log:
 +
{{Code|tail -f /var/log/mail.log}}
  
REF:  [http://ubuntulinux.co.in/blog/ubuntu/set-up-postfix-for-relaying-emails-via-gmail-smtp-server  
+
If all goes well, you should not see any errors.
Set Up Postfix For Relaying Emails via gmail smtp server]
+
 
 +
 
 +
REF:  [http://ubuntulinux.co.in/blog/ubuntu/set-up-postfix-for-relaying-emails-via-gmail-smtp-server Set Up Postfix For Relaying Emails via gmail smtp server]

Revision as of 22:58, 12 July 2012

tags: mail gmail ubuntu postfix relay

Warning.png WARNING
This is recommended only for advanced users, proceed with caution.


This can be used to send mails from your HDA and to receive system emails.
To receive emails meant for the root user, you have to Forward System Emails after finishing this tutorial.

  • Install postfix and remove sendmail:
bash code
​sudo apt-get -y postfix mailutils sudo apt-get -y remove sendmail​


NOTE: During install of postfix, a popup box may display. If it does, select Internet and then OK.

  • Execute the following to update /etc/postfix/main.cf:
bash code
​sudo postconf -e 'relayhost=gmail-smtp-in.l.google.com' sudo postconf -e 'smtp_sasl_auth_enable=yes' sudo postconf -e 'smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd' sudo postconf -e 'smtp_sasl_security_options='


  • Create /etc/postfix/sasl_passwd file with your Gmail login credentials that looks like below:
Text
​gmail-smtp-in.l.google.com user@gmail.com:password​

Obviously, you need to change user to your username and password to your gmail password.

  • Create the password database:
bash code
​sudo postmap hash:/etc/postfix/sasl_passwd​


  • Protect the files with your Gmail login data:
bash code
​sudo chown root:root /etc/postfix/sasl_passwd sudo chmod 600 /etc/postfix/sasl_passwd​


  • Restart Postfix:
bash code
​sudo /etc/init.d/postfix restart​


  • Now try sending a mail, it should reach your Gmail account:
bash code
​echo "This is Content" | sudo mail -s "This is subject" user@gmail.com​


  • Check the mail log:
bash code
​tail -f /var/log/mail.log​


If all goes well, you should not see any errors.


REF: Set Up Postfix For Relaying Emails via gmail smtp server