Configuring exim4 in Ubuntu to use GMail for SMTP


Please read the comments especially if you run into problems. They contain some valuable information which I can't integrate into the guide because of lack of time to test it. Also GMail has limit of 100 messages/day/account when you use SMTP. Keep this in mind :)

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

Step 2

Step 3

That should be it. You can test by using the command line mail client.

This was on an Ubuntu server. I believe that this instructions will also work on Debain without any need for modifications.

blog comments powered by Disqus