<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Within Reason: Use Gmail as a Smart Host</title>
    <link>http://typo.submonkey.net/articles/2005/09/09/use-gmail-as-a-smart-host</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>I do what I want</description>
    <item>
      <title>Use Gmail as a Smart Host</title>
      <description>&lt;p&gt;I like to send mail direct from my home network for various reasons, not least being that I used to work on my current ISP&amp;#8217;s mail servers and I know that they are in and out of blackholes these days like Hawking radiation.  By sending mail directly from my dynamic block, the results are at least somewhat consistent.&lt;/p&gt;

&lt;p&gt;Some may suggest changing ISP, but I am happy with every other aspect of their service, and there is no guarantee that any other ISP won&amp;#8217;t run in to the same problems at any point in the future.  Exim makes it easy for me to maintain a list of domains that do require me to use my ISP&amp;#8217;s smart host, and even has the decency to read it dynamically, so it&amp;#8217;s little hardship for me to:

&lt;code&gt;echo painintheass.net &gt;&gt; /usr/local/etc/exim/smarthost.domains&lt;/code&gt;

for those domains that do need it.&lt;/p&gt;

&lt;p&gt;Occasionally, however, I run into problems whereby the recipient that I am trying to mail won&amp;#8217;t accept mail from me or the upstream smart host at the ISP.  In the past, that has meant that I&amp;#8217;ve been stuffed, which would normally be the would-be recipient&amp;#8217;s problem, but every so often I really, really want to send them the message.&lt;/p&gt;

&lt;p&gt;This just happened twice in the space of ten minutes, so I worked out how to get exim to relay mail via smtp.gmail.com:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;p&gt;First, enable POP for your gmail account.  You do that in the &amp;#8220;Forwarding and POP&amp;#8221; section of the settings.  Strangely enough.&lt;/p&gt;&lt;/li&gt;

  &lt;li&gt;&lt;p&gt;Next, add a domain list to your exim configuration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;domainlist use_gmail_domains = /usr/local/etc/exim/gmail.domains&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This domain list will hold the list of domains to send via gmail, one domain per line.  If you don&amp;#8217;t have any to add now, create the file empty with touch(1) so that you don&amp;#8217;t forget later.  Exim won&amp;#8217;t complain either way.&lt;/p&gt;&lt;/li&gt;

  &lt;li&gt;&lt;p&gt;Create an authenticator.  Note that although we&amp;#8217;re using the plaintext mechanism here, we&amp;#8217;ll force TLS in the transport so your details will not get transferred in the clear:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gmail_login:
  driver = plaintext
  public_name = LOGIN
  client_send = : &lt;em&gt;YourGmailUsername&lt;/em&gt;@gmail.com : &lt;em&gt;YourGmailPassword&lt;/em&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that in a default exim configuration there are usually no authenticators, so don&amp;#8217;t forget the &lt;code&gt;begin authenticators&lt;/code&gt; statement if this is your first one.&lt;/p&gt;&lt;/li&gt;

  &lt;li&gt;&lt;p&gt;Add a router:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;send_via_gmail:
  driver = manualroute
  domains = +use_gmail_domains
  transport = gmail_smtp
  route_list = "* smtp.gmail.com byname"&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Add a transport, forcing it to use AUTH and TLS:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gmail_smtp:
  driver = smtp
  hosts = smtp.gmail.com
  hosts_require_auth = smtp.gmail.com
  hosts_require_tls = smtp.gmail.com&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That&amp;#8217;s all it requires.  You may now need to lock down the permissions on your configuration file to stop anyone reading your username and password from it.  Advanced exim users can work out how to put this information in a separate file easily enough.&lt;/p&gt;</description>
      <pubDate>Fri, 09 Sep 2005 21:36:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a8c86067f27f41d889a372327e062f31</guid>
      <author>Ceri Davies</author>
      <link>http://typo.submonkey.net/articles/2005/09/09/use-gmail-as-a-smart-host</link>
      <category>Mail</category>
      <category>Software</category>
    </item>
    <item>
      <title>"Use Gmail as a Smart Host" by Ceri</title>
      <description>&lt;p&gt;I didn't know about the &lt;code&gt;hide&lt;/code&gt; option, thanks.&lt;/p&gt;

&lt;p&gt;In this case, however, it's not required; client_send is an option in the authenticator setting, so &lt;code&gt;exim -bP&lt;/code&gt; won't display it any more than &lt;code&gt;exim -bP transport&lt;/code&gt; would.&lt;/p&gt;</description>
      <pubDate>Tue, 20 Sep 2005 21:51:14 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.submonkey.net/articles/2005/09/09/use-gmail-as-a-smart-host#comment-101</link>
    </item>
    <item>
      <title>"Use Gmail as a Smart Host" by Dick Davies</title>
      <description>&lt;p&gt;Nice, ta. One thing I'd add is that if you replace&lt;p&gt; 

&lt;p&gt;&lt;pre&gt;&lt;code&gt;client_send: user : pass&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;in the authenticator with &lt;/p&gt;

&lt;p&gt;&lt;pre&gt;&lt;code&gt;hide client_send: user : pass&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;you'll be safe from 'exim -bP client_send' snooping.
Although I might have that wrong.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 20 Sep 2005 21:48:43 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.submonkey.net/articles/2005/09/09/use-gmail-as-a-smart-host#comment-100</link>
    </item>
  </channel>
</rss>
