November 2012 Archives

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 file:

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: "U:root" 
                        "M:PLAIN" "U:root" 

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

As always when dealing with, 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 >
# 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 Here are some other changes to use the ISP's mail server. (In this case I'm using, 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. "U:username" "P:password"


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 >
# service sendmail restart

About Me


  • 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)


Monthly Archives

About this Archive

This page is an archive of entries from November 2012 listed from newest to oldest.

October 2012 is the previous archive.

March 2013 is the next archive.

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