Saturday, 30 August 2014

Using google mail servers as a smarthost from a linux server (ubuntu)

So you want to send mail securely using google's mail servers as a smarthost.

The first thing you'll need is an application specific password for exim.

Once that's created, I will assume the following:
  • You are ok with Gmail rewriting your sender address or use this Gmail address.
  • Your account name on your local Debian box: YOUR-USER-NAME
  • Your host name in /etc/hostname: hostname1
  • Your host name in the 127.0.1.1 line of /etc/hosts: hostname1.localdomain hostname1
  • Your envelope address is SMTPAccountName@gmail.com for the outgoing SMTP connection to Gmail's SMTP server via Exim4
  • Your Exim4 relays local SMTP connections coming with the mail envelope address: YOUR-USER-NAME@localhost and YOUR-USER-NAME@localhost.localdomain
  • Your account name for SMTP at Gmail is SMTPAccountName@gmail.com
  • Your password for SMTP at Gmail is y0uRpaSsw0RD
     
# dpkg-reconfigure exim4-config
 
  • Choose "mail sent by smarthost; received via SMTP or fetchmail"
  • Set to "localhost" for "System mail name:".
  • Set to "127.0.0.1" for "IP-addresses to listen on for incoming SMTP connections" to refuse external connections.
  • Leave as empty for "Other destinations for which mail is accepted:".
  • Leave as empty for "Machines to relay mail for:".
  • Set to "smtp.gmail.com::587" for "IP address or host name of the outgoing smarthost:".
  • Choose "NO" for "Hide local mail name in outgoing mail?".
  • Choose "NO" for "Keep number of DNS-queries minimal (Dial-on-Demand)?".
  • Choose "mbox format in /var/mail/" for "Delivery method for local mail".
  • Choose "YES" for "Split configuration into small files?".
vi /etc/exim4/passwd.client
 
 
add the following lines:
*.google.com:SMTPAccountName@gmail.com:y0uRpaSsw0RD
# chown root:Debian-exim /etc/exim4/passwd.client # chmod 640 /etc/exim4/passwd.client
 
Edit your aliases file
# newaliases
 
# update-exim4.conf
# invoke-rc.d exim4 restart
# exim4 -qff
 
 tada
 
mostly grepped from here 
 
 

No comments:

Post a Comment