Ubuntu – Cannot get exim4 & gmail working

eximgmailUbuntu

I've been following various guides on how to send email from an ubuntu server via exim and my gmail account. I think that i've been around the block so many times on this that i've cocked it up somehow. Can anyone see what's not right?

I don't want to include any real email addresses or domain names in this forum post, so whenever they appear in config files etc i'm going to swap them out as follows. I'm going to use silly names instead of descriptive names so they don't get mixed up with system variables etc.

domain name for the server:                bigspanners.com
username i'm logged into the server as:    jimmy
hostname on the server:                    spanners
"long" hostname (result of `hostname -f`): spanners.bigspanners.com
the gmail address i want to send from:     qwerty.uiop@gmail.com
gmail password:                            abcdefgh               

My exim4 config (/etc/exim4/update-exim4.conf.conf) looks like this:

#/etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='bigspanners.com'
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='mail_spool'

I have this in /etc/exim4/passwd.client file:

# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
gmail-smtp.l.google.com:qwerty.uiop@gmail.com:abcdefgh
*.google.com:qwerty.uiop@gmail.com:abcdefgh
smtp.gmail.com:qwerty.uiop@gmail.com:abcdefgh

And i have this in /etc/email-addresses

# This is /etc/email-addresses. It is part of the exim package
#
# This file contains email addresses to use for outgoing mail. Any local
# part not in here will be qualified by the system domain as normal.
#
# It should contain lines of the form:
#
#user: someone@isp.com
#otheruser: someoneelse@anotherisp.com
jimmy: qwerty.uiop@gmail.com
jimmy@localhost: qwerty.uiop@gmail.com
jimmy@hostname1: qwerty.uiop@gmail.com
jimmy@hostname1.localdomain: qwerty.uiop@gmail.com

I'm trying to send an email like so:

echo "This is a test." | mail -s Testing qwerty.uiop@gmail.com

And i see this in my /var/log/exim4/mainlog file:

2014-04-16 13:57:50 1WaQLW-0002dC-9k <= qwerty.uiop@gmail.com U=jimmy P=local S=445
2014-04-16 13:57:51 1WaQLW-0002dC-9k plain authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsuj
534-5.7.14 B3VqEmiHZ1icpT_O185MznNwotW78A3DdsElZPGAkfsIWQdd5de1lNbXoR-xdqK5Ko_Rs5
534-5.7.14 8zXBl2vzfUDPSF08dULZVaF8z999DpQNslK02DfEG0YcTUOxLqoosEzuxHA1vG-_bIxi9L
534-5.7.14 hMsYKcMkWJ7g4wf4xG-LK6c1sKQhFx-u1zcsUyLykkzI1qtGXYF5NC-ZpdnALCdQZ3hzUh
534-5.7.14 aAoXTLg> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLW-0002dC-9k login authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvT4
534-5.7.14 CHLiBFGLWWXIojohtPd9cIM1vLOt1MMyjSUzcFdXOarqE18FzPPxmU9e32_CveJOax5nnB
534-5.7.14 _7-adgi6NtHxbChOOxjRpd8xZCLgNnSjiHFWcbYeLLCZbv-7l6zylE7poh8nFe7SgTEINk
534-5.7.14 Lx1XvFQH1RuA1HJCwsC6nC-jG_4HQF7TY8ma9PBJWv4gz9fNna7wZFX4eeWtFTgpg7dKrX
534-5.7.14 wGYmwwQ> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLW-0002dC-9k ** qwerty.uiop@gmail.com R=smarthost T=remote_smtp_smarthost: SMTP error from remote mail server after MAIL FROM:<qwerty.uiop@gmail.com> SIZE=1480: host gmail-smtp-msa.l.google.com [173.194.64.108]: 530-5.5.1 Authentication Required. Learn more at\n530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 tz6sm39939105obc.10 - gsmtp
2014-04-16 13:57:51 1WaQLX-0002dT-QM <= <> R=1WaQLW-0002dC-9k U=Debian-exim P=local S=1595
2014-04-16 13:57:51 1WaQLW-0002dC-9k Completed
2014-04-16 13:57:52 1WaQLX-0002dT-QM plain authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt1l
534-5.7.14 LT1ysO4nisev9cFYPlQZ0Lk_Y0VvwVmgOWTJOEbZzYo5JOP9vMCoh-wwEXhq-8pUkhKejG
534-5.7.14 KRUNECT5VykeH6TSNQ8MR8ZoXe36ZZhpiZXCr0Smbjq512Lq_D5tozz9A9o1_JQePR05w6
534-5.7.14 RjyOK481V2Th6RhKwKqlBsvxfWKbs7twgxyklxBTRihFUEkJpFXDzvWNfUNJhkQq0MJnHv
534-5.7.14 53T4KeQ> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM login authenticator failed H=gmail-smtp-msa.l.google.com [173.194.64.108] 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt09
534-5.7.14 0DeijxwxzvClKfwY3oc1IhhkdSt_3suNtEsij4ibdikNtCMCiogd6mOma3obSAu2J5PlVh
534-5.7.14 QnZAN8CalbSYOX7mzuQyVqErqsY9uv5yuObmXk8771WBGrOzIxaOTnzChpd_ZVVeSGfmnh
534-5.7.14 qU5KHUrFo-qvHuYuqNZ1IsnbCkDKpov095uSs9wsbqA2WDEIKMI97EScrbjSNTJ35gdzOx
534-5.7.14 D_2ZhLA> Please log in via your web browser and then try again.
534-5.7.14 Learn more at https://support.google.com/mail/bin/answer.py?answer=787
534 5.7.14 54 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM ** qwerty.uiop@gmail.com R=smarthost T=remote_smtp_smarthost: SMTP error from remote mail server after MAIL FROM:<> SIZE=2655: host gmail-smtp-msa.l.google.com [173.194.64.108]: 530-5.5.1 Authentication Required. Learn more at\n530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 sm4sm23756569obc.3 - gsmtp
2014-04-16 13:57:53 1WaQLX-0002dT-QM Frozen (delivery error message)
2014-04-16 14:00:13 1WaQNg-0002eG-NX <= qwerty.uiop@gmail.com U=jimmy P=local S=2381
2014-04-16 14:00:13 1WaQNg-0002eG-NX == jimmy@localhost R=local_user T=mail_spool defer (13): Permission denied: creating lock file hitching post /var/mail/jimmy.lock.spanners.bigspanners.com.534e8ced.000027cc (euid=1000 egid=8)

Sorry for the longness of this post but i'm trying to provide any info i think might be relevant. Can anyone see what's wrong?

EDIT: i just thought of something else that may be relevant: i have iptables set up to allow all outgoing requests but to block all incoming requests expect for those on a whitelist. I don't know how gmail auth works: could it be that part of the auth process is being blocked because it's coming in on a non-whitelisted port, and that's why it's failing? here's my iptables rules:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             127.0.0.0/8         reject-with icmp-port-unreachable 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:24367 
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:2812 
LOG        all  --  anywhere             anywhere            limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' 
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:2812 

EDIT 2: since posting this i've had notifications from gmail saying "Someone has tried to access your email account, was it you?" (or words to that effect), listing the ip address of my server. I clicked the "Yes, that was me" box, and tried again, but it's still not working.

Best Answer

Had the same issue for a few hours now, but it's not the configuration it's google which blocks the account access, because you try to login from an other IP then normally.

Open http://www.google.com/accounts/DisplayUnlockCaptcha and then try to send an e-mail using for example: echo 'My Test Text' | mail -s Testmail max.mustermann@domain.com

/etc/exim4/passwd.client :

# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password

gmail-smtp.l.google.com:max.mustermann@gmail.com:yourpassword
*.google.com:max.mustermann@gmail.com:yourpassword
smtp.gmail.com:max.mustermann@gmail.com:yourpassword

/etc/exim4/update-exim4.conf.conf :

# /etc/exim4/update-exim4.conf.conf
# (...)
# This is a Debian specific file

dc_eximconfig_configtype='satellite'
dc_other_hostnames='ServerName'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='yourdomain_which_points_to_server.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
Related Topic