Follow Techsutra on Twitter
Configuring exim4 in Ubuntu to use GMail for SMTP
This blog runs on wordpress and the “comment notifications by email” never worked. Initially I thought it was a wordpress problem and trawled through forum posts looking for a solution. Unable to find one I did something which I should have tried right at the beginning. I tried sending a mail from the server using the ‘mail’ command. Oops !. Exim log(/var/log/exim4/mainlog) give the wonderfully worded message R=nonlocal: Mailing to remote domains not supported
Also I wanted to route the mail through GMail SMTP servers since that would improve reliability. Turns out there is an indeed a way to make exim, the default MTA in debain/ubuntu to route all mail through GMail SMTP servers. Second round of trawling the interwebs started I managed to get a working setup without much trouble. But I had to piece together the content from separate sources. Here is how I did it.
Step 1
Run dpkg-reconfigure exim4-config
- Choose mail sent by smarthost; received via SMTP or fetchmail
- Type System Mail Name: e.g. company.com
- Type IP Adresses to listen on for incoming SMTP connections: 127.0.0.1
- Leave Other destinations for which mail is accepted blank
- Leave Machines to relay mail for: blank
- Type Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587
- Choose NO, don’t hide local mail name in outgoing mail.
- Chose NO, don’t keep number of DNS-queries minimal (Dial-on-Demand).
- Choose mbox
- Choose NO, split configuration into small files
- Mail for postmaster. Leaving blank will not cause any problems though it is not recommended
Step 2
- Open the file /etc/exim4/exim4.conf.template
- Find the line .ifdef DCconfig_smarthost DCconfig_satellite and add the following in that section
send_via_gmail: driver = manualroute domains = ! +local_domains transport = gmail_smtp route_list = * smtp.gmail.comIf you have any other smarthost defined with “domains = ! +local_domains” remove that smarthost.
- Find the “begin authenticators”. In that section add the following
gmail_login: driver = plaintext public_name = LOGIN client_send = : yourname@gmail.com : YourGmailPasswordMake sure you have no other authenticators with the same public_name (LOGIN). Comment them out if needed (Thanks Jakub for reminding me)
- Find the comment “transport/30_exim4-config_remote_smtp_smarthost”. In that section add
gmail_smtp: driver = smtp port = 587 hosts_require_auth = $host_address hosts_require_tls = $host_address
Step 3
- Run update-exim4.conf
- Do /etc/init.d/exim4 restart
That should be it. You can test by using the command line mail client.
- Run mail user@example.com
- Give a subject and press enter
- Type something and press enter
- Type a single . (dot) and press enter
- Press enter for a blank CC:
This was on an Ubuntu server. I believe that this instructions will also work on Debain without any need for modifications.
-
Jakub
-
Kim
-
BassKozz
-
yotnottin
-
Manu J
-
yotnottin
-
Manu J
-
yotnottin
-
Manu J
-
Manu J
-
yotnottin
-
Manu J
-
remy215
-
Tim
-
Dave Marples
-
Richard
-
John Pope
-
John Pope
-
Nagin
-
Julian
-
Julian
-
Sadhanandhan
-
Manu J
-
Sadhanandhan
-
BassKozz
-
Hanno
-
Manson Thomas
-
Manson Thomas
-
Manson Thomas
-
Manson Thomas
-
Manson Thomas
-
Lars Dongrie Oppholdsnes
-
Manu J
-
Lars Dongrie Oppholdsnes
-
Manson Thomas
-
Thomas
-
Ruth
-
Michael Lesniak
-
kripz
-
Manu J
-
kripz
-
Javich
-
swk
-
swk
-
swk
-
grwk






