using gmail as a smart host

|

Problem: My new ISP blocks outgoing port 25 (SMTP) and I want to run a mail server from home.

Solution: I need to set up sendmail so that it uses gmail (or my ISP) as the outgoing smart host.

You'll need SASL running, so yum or apt-get that. Then add the following to your sendmail.mc file:

TRUST_AUTH_MECH(`LOGIN PLAIN GSSAPI DIGEST-MD5 CRAM-MD5')dnl
define(`confAUTH_MECHANISMS', 
       `EXTERNAL LOGIN PLAIN GSSAPI DIGEST-MD5 CRAM-MD5')dnl
define(`SMART_HOST',`relay:smtp.gmail.com')dnl
define(`RELAY_MAILER', `esmtp')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/authinfo.db')dnl

Make an authinfo: /etc/mail/auth/authinfo, chmod it to 0600, and have the following lines in it:

AuthInfo:smtp.gmail.com "U:root" 
                        "I:username@gmail.com" 
                        "P:password" 
                        "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:root" 
                            "I:username@gmail.com" 
                            "P:password" 
                            "M:PLAIN"

(Note: these should actually be all on one line per entry, so two lines for the above.)

As always when dealing with sendmail.mc, you'll need to run the m4 processor over the file and make the hash maps. Do yourself a favour and have a Makefile to do it for you. Restart sendmail, and you should be good to go!

# makemap hash authinfo.db < auth/authinfo
# m4 sendmail.mc > sendmail.cf
# service sendmail restart

And note that if you use Application Specific passwords (i.e. 2 step authentication), you'll need to generate a password for this.

Helpful info from:

UPDATE: While the above is fine and works, Google's mail servers rewrite the From: address to the gmail account you use to authenticate. This is not the best solution if you want to not appear to only be able to send from gmail.com. Here are some other changes to use the ISP's mail server. (In this case I'm using netvigator.com, others should be similar.)

/etc/mail/auth/authinfo (Note that I don't need to specify the higher ports, as the ISP only accepts on port 25. The Method ("M:PLAIN") doesn't seem to be required either.

AuthInfo:smtp.netvigator.com "U:username" "P:password"

/etc/mail/sendmail.mc

define(`SMART_HOST',`relay:smtp.netvigator.com')dnl
define(`RELAY_MAILER', `esmtp')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/authinfo.db')dnl

And to enable all this:

# makemap hash authinfo.db < auth/authinfo
# m4 sendmail.mc > sendmail.cf
# service sendmail restart

About Me

Contact

  • Unsolicited Bulk Email (spam), commercial solicitations, SEO related items, link exchange requests, and abuse are not welcome here and will result in complaints to your ISP.
  • Any email to the above address may be made public at the sole discretion of the recipient.

Other Stuff

  • Powered by Linux
  • (RedHat Linux)

Categories

Monthly Archives

About this Entry

This page contains a single entry by dave published on November 16, 2012 2:33 PM.

Today's Wibblinks 10/20/2012 (p.m.) was the previous entry in this blog.

Infographic: How Climate Change is Destroying the Earth is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.