Using Gmail as a Sendmail Relay
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!
You are amazing. I have been trying this for days. Thank you.
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
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.