Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Well I can see one error immediately: your /etc/exim4/update-exim4.conf.conf has one too many colons: dc_smarthost='smtp.gmail.com::587'. However, I'm not sure if that's what's causing your errors. –  bennettp123 Apr 17 at 7:06
    
@bennettp123 - are you sure? Every guide i looked at has two colons, eg wiki.debian.org/GmailAndExim4 tompurl.com/2011/09/17/exim-gmail-on-ubuntu islandlinux.org/howto/configure-exim-use-gmail-smtp-server –  Max Williams Apr 17 at 9:25
    
not as sure as I was 7 hours ago. I assumed that the correct syntax was server:port, but your examples all show server::port. And my own server runs on port 25, so it's just server. :) –  bennettp123 Apr 17 at 14:27
    
It seems more to be like a problem with the credentials. Have you double-checked them? Do you have any special chars in it? –  german_guy Apr 24 at 7:53
    
@german_guy the credentials are definitely correct: i just double-checked by pasting them from the passwd.client file into the login box in gmail in my web browser. There are no special chars. –  Max Williams Apr 24 at 8:49

2 Answers 2

up vote 2 down vote accepted

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'
share|improve this answer
    
That's worked! Halleflippinglujah, thanks @FireEmerald! –  Max Williams Dec 10 at 16:21

Gmail authentication will fail if tls negotiation does not complete properly . Check you're indeed using starttls when talking to gmail. You can run exim with -d-all+tls+transport.

That should give more infos

share|improve this answer
    
Thanks @alxgomz. Can you tell me how i should start exim in this way? I tried doing sudo /etc/init.d/exim4 stop; sudo /etc/init.d/exim4 start -d-all+tls+transport but i'm not sure if that was the right way to do it: it didn't make any difference. –  Max Williams Apr 29 at 10:24
    
Actually it depends on your distro, but if you use a Debian like version of Linux, you can set the debug flags in /etc/default/exim4. Be aware that this will make the process run in foreground so you don't want to s stay like this for too long. Particularly not when you reboot!! –  alxgomz Apr 29 at 16:35
    
really sorry but do you mind explaining what -d-all+tls+transport actually does? Is it to do with debugging as your last comment implies? Also, what would i look out for in the debug output to see if starttls is being used properly? –  Max Williams Apr 30 at 9:00
    
this switch will indeed activate debug for tls negotiation and exim transports (including the smtp one that is supposed to deliver mail to gmail). It is quite difficult to forecast what will be the error and hance the need for debugging :). But for example seraching for the gmail address you're trying to reach or the remote server name can be a starting point. –  alxgomz Apr 30 at 13:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.