My words on free/open source software

Wednesday, March 21, 2007

Use Exim with Gmail SMTP on Fedora

I've managed to setup Exim to send mail via Gmail SMTP on my laptop running Fedora Core 6. It was a bit tough work, for I can't find any precedent of using it on Fedora. Most talkings and guides regards Exim were based on Debian, and Fedora just doesn't have that config tools of Debian.

If you just want to know what to do, skip this paragraph, which talks theoratical things. My work started by following Use Gmail as a Smart Host, but it doesn't work. Checked Exim's log I found that the connection to Gmail's SMTP server was rejected, because Exim had been trying to connect to port 25 of it. Add a line "port = 587" solved this problem. Another problem is about the TLS authentication, because Exim thought the server it were to connect is called "gmail-smtp.l.google.com", which was got through DNS lookup, rather than the "smtp.gmail.com" set by me. So in the configure file, you should use "gmail-smtp.l.google.com" instead of "smtp.gmail.com."

So what to do is: edit "/etc/exim/exim.conf", add:

# routers section
send_via_gmail:
driver = manualroute
domains = ! +local_domains
transport = gmail_smtp
route_list = * gmail-smtp.l.google.com

# transports section
gmail_smtp:
driver = smtp
port = 587
hosts_require_auth = gmail-smtp.l.google.com
hosts_require_tls = gmail-smtp.l.google.com

# authenticators section
gmail_login:
driver = plaintext
public_name = LOGIN
client_send = : youraccount@gmail.com : yourpassword


I do think Exim should write an official FAQ regards this problem.

For some time, you may see such errors in Exim's log:

SMTP timeout while connected to gmail-smtp.l.google.com [72.14.253.109] after EHLO yourhostname: Conne
ction timed out


This is network or Gmail's problem. Want you can do is just waiting or switch to another ISP and try.

4 comments:

Anonymous said...

This also works on OpenSUSE 11 and was the easiest way I found to send email through gmail. Thank you Yan Li!

laquack said...

I had problems setting up postfix and used exim instead...this smtp.gmail.com bug is really confusing people.Thanks for the advice.

NixURL said...

Hey Yan,

How to track the mail which is sent to gmail. Because, I set up the relay serer as gmail as u mentined, but i couldnt trace anything in the logs, or in the exim queue.. Neither the mail comes to my inbox...


[root@www ~]# mail -s "Hello World" anzwaits@gmail.com
.
Cc: .
Null message body; hope that's ok
[root@www ~]#
[root@www ~]# tail -f /var/log/exim/main.log

2012-01-01 19:07:06 exim 4.63 daemon started: pid=26067, -q1h, listening for SMTP on [192.168.229.128]:25 [192.168.229.128]:587 [::1]:25 [::1]:587 and for SMTPS on [192.168.229.128]:465 [::1]:465
2012-01-01 19:07:06 Start queue run: pid=26068
2012-01-01 19:07:06 End queue run: pid=26068


[root@www ~]#
[root@www ~]# exim -bpc
0
[root@www ~]#



Can u help me on this???

Thanks much !!
-aneesh

NixURL said...

Hey Yan,

I fixed it !!

2 things to remember.

1. Add proper firewall rule to connect to the smtp server or swith off the firewall for testing..

2. The 'mail' command was invoking my old sendmail binary even though it was in disabled status. I moved it to temp and created a symbolic link for the same and the issue got fixed !!


2012-01-01 20:20:48 1RhKOp-00072q-Cu gmail-smtp.l.google.com [209.85.143.108] Connection refused
2012-01-01 20:20:48 1RhKOp-00072q-Cu == aneeshptr007@gmail.com R=send_via_gmail T=gmail_smtp defer (111): Connection refused
2012-01-01 20:23:00 Start queue run: pid=27096 -qff
2012-01-01 20:23:08 1RhKOp-00072q-Cu => aneeshptr007@gmail.com R=send_via_gmail T=gmail_smtp H=gmail-smtp.l.google.com [74.125.45.108] X=TLSv1:RC4-SHA:128
2012-01-01 20:23:08 1RhKOp-00072q-Cu Completed

Also I tried with the smtp settings

smtp.gmail.com, port 587

This is also working as expected.
Kudooos !!

-aneesh

About Me

My photo
Santa Cruz, California, United States