configure exim4 to send email through gmail account

At first I sent email using exim4 and my gmail account as explained in this post, but suddenly it stopped working. Looks like gmail changed access to smtp.

I looked for information on how to set up exim4 to send email through gmail account, but hardly found anything until I stumbled upon a very great guide: http://www.manu-j.com/blog/wordpress-exim4-ubuntu-gmail-smtp/75/

I’ve reproduced all the steps right here, just in case of. In any case, thank you so much manu-j, you rule!

step 1: reconfiguring exim4

run “sudo dpkg-reconfigure exim4-config” and choose:

  • 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, do not split configuration into small files
  • Mail for postmaster. Leaving blank will not cause any problems though it is not recommended

step 2: edit configuration file

Here we will edit /etc/exim4/exim4.conf.template and do the following:

  1. 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.com

    If you have any other smarthost defined with “domains = ! +local_domains” remove that smarthost.
    In my case, I commented the entire  ”smarthost:” section (prepend ‘#’ to each line of this section, including the section title)

  2. Find the “begin authenticators”. In that section add the following
    gmail_login:
       driver = plaintext
       public_name = LOGIN
       client_send = : yourname@gmail.com : YourGmailPassword

    Make sure you have no other authenticators with the same public_name (LOGIN). Comment them out if needed.
    In my case, I commented the entire “login:” section.

  3. 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: update & reload exim4

First, update exim4: “sudo update-exim4.conf”
then reload it: “sudo /etc/init.d/exim4 restart”

That’s it! You can try to send an email using “mail” function (cf. package bsdx, cf. this post) and receive it in your gmail account.

Thank you so much manu-j, you’re the man!

sources

One Response to “configure exim4 to send email through gmail account”

  1. Manu says:

    Hi, I’m Manu and can please you remove the steps you have copied here. I personally don’t have a problem with it but I think because of it I got penalized by google (for content duplication). Now my guide has disappeared from google for all the keywords for which it used to rank high.

Leave a Reply