Saturday, 4 April 2009

Send mail through gmail smtp server with Exim4 - What to do when gmail account has been disabled

To send mail from a machine using gmail smtp server see this tutorial :

I've just ran into a problem with this config.

I've created a gmail account just for this purpose because you need to set the gmail account password in exim4 configuration file on each machine.
I didn't want to use my personnal gmail account for obvious reasons.

As it's a technical account, I never log into it through web interface.

Which lead to the account beeing disabled by gmail.
As a result, all mail that exim4 tryed to send gives this warning message in /var/log/exim4/mainlog :

R=send_via_gmail T=gmail_smtp defer (-53): retry time not reached for any host

To solve this issue, you need to

  1. Login to with the account you use with exim4. It will ask you to login a second time with a captcha... do so
  2. login on all of your machine that use this technique and issue the following command :

    sudo exim -qff
and you should now recieve all mail which was unsent.
In exim4 logs you should see the following line :

2009-04-04 17:07:44 1Lq7Jf-0007WM-VJ => R=send_via_gmail T=gmail_smtp [] X=TLS1.0:RSA_ARCFOUR_MD5:16 DN="C=US,ST=California,L=Mountain View,O=Google Inc,"
2009-04-04 17:07:44 1Lq7Jf-0007WM-VJ Completed

One more thing, don't forget to login once in a while on your gmail account so that it's not disabled. A solution is maybe a firefox extension like gmail manager.


elfar said...

Thanks for a great post, helped confirm my suspicions and the exim -qff was great to know. I am doing something similar and was wondering if you have any idea how often gmail will add this captcha block when you do not login? And also did the firefox extension help or could you find some third way of avoiding logging manually? Guess it would be possible with some simple script and have it login via cron once in a while...

Manson Thomas said...

Well, the gmail manager works perfectly for me.

Since I run my firefox every day at work, it keeps a 'login activity' so that my account isn't disabled.

I guess there's some api that allow gmail manager to login, so It should'nt be impossible to script this and cron it.

Octavio said...

Do you know if there is a way to hide or replace de gmail account from the header "from" with another account name?

Manson Thomas said...

I don't think it's possible, I've read somewhere that gmail won't let you totally remove the identity. (spam protection I guess)

Octavio said...

thanks for the response, i'm having a problem with my exim smarthost configuration, that why i tried to use gmail, but if I cant change the name of the account I cant use it. Do you know why if I set my isp smtp and fill the passwd.client file in a proper way all my email are reject (except the local ones and the accounts that belong to my isp).
Any ideas?

Manson Thomas said...

Octavio, you should ask on the exim user mailing list.

Subscribe there :

Include your configuration and logs with something like

That's the best place to get help.

I've configured exim for my servers and and don't know much more about it. I know postfix better.