The revenge this time its personal!
K I just setup sendmail to relay using gmail again, thought I better post what I have done as my original now out of date post is still getting quite a lot of views.
This is based on my Ubuntu 8.10 Server ( 2.6.27-11-server) all patched up todays date and then I did the below.
First off make sure you can actually resolve gmail.com, working ? good.
sudo apt-get install sendmail sudo cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.orig sudo vi /etc/mail/sendmail.mc
Add the following to the bottom of your virgin sendmail.mc (shift+g to get to end of file):
define(`SMART_HOST',`smtp.gmail.com')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs') define(`confCACERT_PATH', `CERT_DIR') define(`confCACERT', `CERT_DIR/CAcert.pem') define(`confSERVER_CERT', `CERT_DIR/mycert.pem') define(`confSERVER_KEY', `CERT_DIR/mykey.pem') define(`confCLIENT_CERT', `CERT_DIR/mycert.pem') define(`confCLIENT_KEY', `CERT_DIR/mykey.pem')
Save the file.
sudo mkdir /etc/mail/auth sudo vi /etc/mail/auth/client-info
Add the following line to the new client-info file replacing the text between the greater than and less than signs (did I need to spell that out ?):
AuthInfo:smtp.gmail.com "U:root" "I:<YOUR GMAIL USERNAME HERE>@gmail.com" "P:<YOU GMAIL PASSWORD HERE>"
Save the file.
makemap hash client-info < client-info chmod 700 /etc/mail/auth chmod 600 /etc/mail/auth/* mkdir /etc/mail/certs cd /etc/mail/certs openssl dsaparam 1024 -out dsa1024 -out dsa1024.pem openssl req -x509 -nodes -days 3650 -newkey dsa:dsa1024.pem -out /etc/mail/certs/mycert.pem -keyout /etc/mail/certs/mykey.pem ln -s /etc/mail/certs/mycert.pem /etc/mail/certs/CAcert.pem openssl req -x509 -new -days 3650 -key /etc/mail/certs/mykey.pem -out /etc/mail/certs/mycert.pem chmod 700 /etc/mail/certs chmod 600 /etc/mail/certs/* cd /etc/mail make /etc/init.d/sendmail reload
Bish Bosh!
James






You are amazing. I have been trying this for days. Thank you.
Pingback: Getting sendmail to use gmail as a relay. | James Lloyd
Thank you very much, that was exactly what I needed and it saved a lot of time (I guess). Cheers!
May be worth mentioning they also work fine on CentOS
This works on Ubuntu 8.04.2 as well. Thanks for posting this, it was a big help.
[root@pbx-xen auth]# makemap hash client-info < client-info
makemap: error opening type hash map client-info: Permission denied
on centos?
silly me didnt use sudo to create
so i sendmail and it still uses localhost etc, it doesnt use smtp settings
Pingback: Configuring Sendmail to relay through Gmail SMTP « The AppGirl Blog
FYI just used this on 9.04 works flawlessly.
Thanks for the tips. For Fedora users, the additional configuration belongs right around the existing “SMART_HOST” config in the sendmail.mc. Then, after installing sendmail-cf package, you issue:
make sendmail.cf -C /etc/mail
/etc/init.d/sendmail restart
I found that this works just fine without doing any of the client certificate stuff. All I had to do (on Fedora 11) was:
* Add the first 3 lines to sendmail.mc
* Create /etc/mail/auth/client-info with the given contents
* Set the permissions of /etc/mail/auth and /etc/mail/auth/client-info
* Run the makemap command
* cd /etc/mail && make
* service sendmail restart
Why does need cert?
I can send with and without cert. Message is sending without problem except..
In both ways I got answer:
STARTTLS=client… verify=FAIL
You rock! You are ace! Pulled out all my hair trying to get this, and you were spot on. I am naming all my children after you, because you were named before them. Schweet!
Thank you very much James!!
Short, easy and it works!
That was too easy
Thanks
Danke!
Thank you! This works in Slackware 13 with some minor modifications:
- Edit ‘/usr/share/sendmail/cf/cf/sendmail-slackware.mc’ instead of ‘/etc/mail/sendmail.mc’ (be sure to back up the original)
- Add the needed lines – make sure the FEATURE line appears ahead of any MAILER lines in the file.
- Rather than running ‘make’ in the ‘/etc/mail’ dir, run `m4 sendmail-slackware.mc > /etc/mail/sendmail.cf’ in the ‘/usr/share/sendmail/cf/cf/’ directory as root
- Once done, restart sendmail by running ‘/etc/rc.d/rc.sendmail restart’
The other steps are the same.
Who test this server, i how send a test mail ??
How do you send a test mail?
Thanks James. I found this really usefull.
thanks james… this page is in my bookmarks… since long time
greetings,
I’m testing this on Ubuntu 9.10, but it seems I can’t make it work. Can you please tell me if this was tested on Ubuntu 9.10? My machine is updated
Its been tested on an up to date 9.04 as am skipping 9.10 on my server. Though cant’ think of any major changes that would stop it working.
Yuck. I’m on centos 5.4; I took the sendmail.mc that is provided as a default for sendmail.
All the suggested setup provided above, and the connection is refused by gmail.
Using the -X option added on sendmail daemon startup, I see this in the log:
13211 === CONNECT smtp.gmail.com
13211 <<>> EHLO bromley.whatever.com
13211 <<< 250-mx.google.com at your service, [174.143.244.25]
13211 <<< 250-SIZE 35651584
13211 <<< 250-8BITMIME
13211 <<< 250-STARTTLS
13211 <<>> STARTTLS
13211 <<>> EHLO bromley.whatever.com
13211 <<< 250-mx.google.com at your service, [174.143.244.25]
13211 <<< 250-SIZE 35651584
13211 <<< 250-8BITMIME
13211 <<< 250-AUTH LOGIN PLAIN XOAUTH
13211 <<>> MAIL From: SIZE=639
13211 <<< 530-5.5.1 Authentication Required. Learn more at
13211 <<>> This is a MIME-encapsulated message
13211 >>>
…
I’ve been trying all sorts of tweaks, I get the same stuff over and over. What does it take to get the authentication sent to gmail? Any suggestions?
This may work for a normal gmail account but it is not working with my Google apps mail account. It requires an SSL connection on port 465.
Please help.
Thanks.
Though im a heavy google apps user i have never tried that, should note that I have tried my solution on 10.04 with no luck.
However Im currently using Sendmail installed on 10.04 with zero config tweaks to sendmail to sendmail. The only change i have made is to edit the hosts file to reflect my google apps domain. As Google will reject email that are sent from localhost.localdomain (quite rightly). This works on its own. However I would recommend then setting up your SPF record to include your sendmail server.
Hope that helps.