<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Bloggitation comments on ActiveMailer sending via GMail</title>
    <link>http://typo.onxen.info/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Bloggitation comments</description>
    <item>
      <title>"ActiveMailer sending via GMail" by stoyan</title>
      <description>&lt;p&gt;On the previous Kansai Rails Conference in Asiyagawa somebody asked me about using GMail (smtp+ssl or tls) with Rails ActiveMailer. Didn&amp;#8217;t find solution until now but &amp;#8216;dza-dza-dzaaaaaaan&amp;#8217; (hahaha i&amp;#8217;m not so smart, all credits going to &lt;a href="http://rails.techno-weenie.net/user/entombedvirus"&gt;entombedvirus&lt;/a&gt; ):&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://rails.techno-weenie.net/tip/2006/6/15/send_email_with_actionmailer_through_tls_only_smtp_server"&gt;Send email with ActionMailer through &lt;span class="caps"&gt;TLS&lt;/span&gt; only &lt;span class="caps"&gt;SMTP&lt;/span&gt; server&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;So for Debian (Ubuntu):&lt;/p&gt;


	&lt;h4&gt;Install msmtp (light &lt;span class="caps"&gt;SMTP&lt;/span&gt; client with support for server profiles)&lt;/h4&gt;


&lt;pre&gt;
$ sudo apt-get install msmtp
&lt;/pre&gt;

	&lt;h4&gt;Create/edit ~/.msmtprc&lt;/h4&gt;


&lt;pre&gt;
account gmail
host smtp.gmail.com
auth on
user &amp;lt;your_account&amp;gt;@gmail.com
password &amp;lt;your_password&amp;gt;
tls on
tls_starttls on
from &amp;lt;your_account&amp;gt;@gmail.com
maildomain gmail.com
account default : gmail
&lt;/pre&gt;

	&lt;h4&gt;Stop msmtp complaining about permissions&lt;/h4&gt;


&lt;pre&gt;
$ chmod 600 ~/.msmtprc
&lt;/pre&gt;

	&lt;h4&gt;Add on the bottom of yourrailsapp/config/environment.rb (and comment another ActionMailer::Base.delivery_method settings if exists)&lt;/h4&gt;


&lt;pre&gt;
ActionMailer::Base.delivery_method = :msmtp

module ActionMailer
  class Base
    def perform_delivery_msmtp(mail)
      IO.popen("/usr/bin/msmtp -t -C /&amp;lt;path_to&amp;gt;/.msmtprc -a gmail --", "w") do
 |sm|
        sm.puts(mail.encoded.gsub(/\r/, ''))
        sm.flush
      end
    end
  end
end
&lt;/pre&gt;

	&lt;p&gt;Do not forget to fix the exact path to your .msmtprc in the source above.&lt;/p&gt;

</description>
      <pubDate>Tue, 27 Jun 2006 01:03:00 PDT</pubDate>
      <guid>&lt;a href="/articles/2006/06/27/activemailer-sending-via-gmail"&gt;ActiveMailer sending via GMail&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2006/06/27/activemailer-sending-via-gmail"&gt;ActiveMailer sending via GMail&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
