Monday, September 29, 2014

Setting up exim4 to use gmail as smarthost to forward mail.

1) Reconfigure exim4

sudo dpkg-reconfigure exim4-config

There we have a set of questions, the important answers are:

Choose: mail sent by SMARTHOST; received via SMTP or fetchmail
In system mail name type: localhost
In IP Adresses to listen on for incoming SMTP connections type127.0.0.1
Leave Other destinations for which mail is accepted blank
Leave Machines to relay mail for blank too
In Machine handling outgoing mail for this host (smarthost) type: smtp.gmail.com::587
(NOTE THAT THE ‘::’ ARE NOT A TYPO)
IP address or host name of the outgoing smarthost: gmail-smtp-msa.l.google.com
Choose NO in response to don’t hide local mail name in outgoing mail
Choose NO in response to don’t keep number of DNS-queries minimal (Dial-on-Demand)
Choose YES in response to split configuration into small files

2) Final touchs

Now we need to tell exim4 about your gmail credentials:

sudo vi /etc/exim4/passwd.client

There we are going to put the following text, replacing where needed:

gmail-smtp.l.google.com:ClockingIT@warehouseoptimization.com:password
  • .google.com:ClockingIT@warehouseoptimization.com:password
smtp.gmail.com:ClockingIT@warehouseoptimization.com:password

Note: You can find out what password is by looking in the file.

And finally we need to tell exim4 how it should bind the system account with the gmail account:

sudo vi /etc/exim4/email-addresses

There we are going to put the possible users:

support@localhost:ClockingIT@warehouseoptimization.com
root@localhost:ClockingIT@warehouseoptimization.com

3) Restart exim4

sudo update-exim4.conf
sudo /etc/init.d/exim4 restart