<?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>Segment7: ar_mailer</title>
    <link>http://blog.segment7.net/articles/2006/08/15/ar_mailer</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Blog</description>
    <item>
      <title>ar_mailer</title>
      <description>&lt;p&gt;Rubyforge Project:

&lt;a href="http://rubyforge.org/projects/rctools"&gt;http://rubyforge.org/projects/rctools&lt;/a&gt;

&lt;p&gt;Documentation:

&lt;a href="http://dev.robotcoop.com/Tools/ar_mailer"&gt;http://dev.robotcoop.com/Tools/ar_mailer&lt;/a&gt;

&lt;h3&gt;About&lt;/h3&gt;

&lt;p&gt;Even deliviring email to the local machine may take too long when you have to
send hundreds of messages.  ar_mailer allows you to store messages into the
database for later delivery by a separate process, ar_sendmail.

&lt;h3&gt;Installing ar_mailer&lt;/h3&gt;

&lt;p&gt;Just install the gem:

&lt;pre&gt;&lt;samp&gt;$ sudo gem install ar_mailer&lt;/samp&gt;&lt;/pre&gt;

&lt;h3&gt;Converting to ar_mailer&lt;/h3&gt;

&lt;p&gt;Go to your Rails project:

&lt;pre&gt;&lt;samp&gt;$ cd your_rails_project&lt;/samp&gt;&lt;/pre&gt;

Create a new migration:

&lt;pre&gt;&lt;samp&gt;$ ar_sendmail --create-migration&lt;/samp&gt;&lt;/pre&gt;

You'll need to redirect this into a file. If you want a different name provide the &amp;mdash;table-name option.

Create a new model:

&lt;pre&gt;&lt;samp&gt;$ ar_sendmail --create-model&lt;/samp&gt;&lt;/pre&gt;

You'll need to redirect this into a file. If you want a different name provide the &amp;mdash;table-name option.

Change your email classes to inherit from ActionMailer::ARMailer instead of ActionMailer::Base:

&lt;pre&gt;&lt;samp&gt;--- app/model/emailer.rb.orig   2006-08-10 13:16:33.000000000 -0700
+++ app/model/emailer.rb        2006-08-10 13:16:43.000000000 -0700
@@ -1,4 +1,4 @@
-class Emailer &lt; ActionMailer::Base
+class Emailer &lt; ActionMailer::ARMailer

def comment_notification(comment)
  from comment.author.email&lt;/pre&gt;&lt;/samp&gt;

Edit config/environments/production.rb and set the delivery agent:

&lt;pre&gt;&lt;samp&gt;$ grep delivery_method config/environments/production.rb
ActionMailer::Base.delivery_method = :activerecord&lt;/samp&gt;&lt;/pre&gt;

Run ar_sendmail:

&lt;pre&gt;&lt;samp&gt;$ ar_sendmail&lt;/samp&gt;&lt;/pre&gt;

You can also run ar_sendmail from cron with -o, or as a daemon with -d.

See ar_sendmail -h for full details.
</description>
      <pubDate>Tue, 15 Aug 2006 16:39:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:245eff9d-8d6b-4a37-a3f3-f219b2719709</guid>
      <author>drbrain@segment7.net (Eric Hodel)</author>
      <link>http://blog.segment7.net/articles/2006/08/15/ar_mailer</link>
      <category>Rails</category>
      <category>Software</category>
    </item>
    <item>
      <title>"ar_mailer" by Eric Hodel</title>
      <description>&lt;p&gt;Yes, you&amp;#8217;ve got to require &amp;#8216;action_mailer/ar_mailer&amp;#8217; after the config block, otherwise the paths don&amp;#8217;t get set correctly.  You can set the mailer in the config block though, the initializer doesn&amp;#8217;t care.&lt;/p&gt;</description>
      <pubDate>Tue, 05 Sep 2006 11:27:46 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:bea66884-65ba-47f4-97ff-5c2c95db5979</guid>
      <link>http://blog.segment7.net/articles/2006/08/15/ar_mailer#comment-337</link>
    </item>
  </channel>
</rss>
