Configure Exim4 on Debian Etch/Lenny/Sid to use Gmail as a SmartHost

How to configure Exim to send email using a Gmail account as a Smart Host. After following this guide, Exim should be able to send email out to the internet via your Google Gmail account.

1. Prepare Exim4 using dpkg

dpkg-reconfigure exim4-config

Selections:

a) General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail

b) System mail name: localhost

c) Ip Addr to listen on: 127.0.0.1

d) Other destinations~: <blank>

e) Machines to Relay for: <blank>

f) ip address or hostname of the outgoing smarthost: smtp.gmail.com::587

g) Hide local mail name in outgoing mail: No

h) Keep number of DNS queries minimal: No

i) Delivery method for local mail: Maildir format in home directory

j) Split configuration into small files: Yes

2. As root, edit /etc/exim4/passwd.client and add the following.

Don’t forget to change emailaddress@gmail.com to your own email address and password to your own password:

gmail-smtp.l.google.com:emailaddress@gmail.com:password
*.google.com:emailaddress@gmail.com:password
smtp.gmail.com:emailaddress@gmail.com:password

Note: You are probably worried about having your password in this file – don’t worry, we’ll make sure the permissions are set correctly in the next step.

3. Set permissions on the /etc/exim4/passwd.client file

Type the following, as root, in the console:

chmod 640 /etc/exim4/passwd.client
chown root:Debian-exim /etc/exim4/passwd.client

4. Add/Edit the /etc/exim4/email-addresses file

In the console as root, add or edit the /etc/exim4/email-addresses file. Just add the following line (no others)

your-local-user-name@localhost:    your-gmail-email-address

And set permissions:

chmod 640 /etc/exim4/email-addresses

5. Edit the /etc/exim4/update-exim4.conf.conf file

It should look like the following:

dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

6. Restart Exim

/etc/init.d/exim4 restart

That should be it!

5 Responses

  1. Val Says:

    Thanx Man. I finally got it working :) )

    Geniality is in Simplicity !!!

  2. Oz Says:

    Hi,
    Thanks for your great tutorial.
    I was wondering what is the easiest way to make sure that this config is working. Looking for the simplest command to send mail directly from cli…

  3. Utilizar GMail como SmartHost desde Linux Debian 5 | Jorge Iván Meza Martínez Says:

    [...] Configure Exim4 on Debian Etch/Lenny/Sid to use Gmail as a SmartHost. http://tarsysco.com/blogs/2008/06/18/configure-exim4-on-debian-etchlennysid-to-use-gmail-as-a-smarth... [...]

  4. varun Says:

    I was trying configuring exim4,I am happy enough with your post.But I do have two problems while configuring.

    1)/etc/exim4/email-addresses file is not present.(manually added)
    2)Error:connection dropped by imap server

  5. varun Says:

    I am able to resolv the above problem by heaven sake..
    -create a folder “Maildir” in the user’s home using “maildirmake Maildir”
    -In the console type the following command
    chown -R username:username Maildir/

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.