Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A two-phase delivery agent for ActionMailer which works for Rails 3.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin initial commit
lib
share
.gitignore
History.txt
LICENSE.txt
README.rdoc
Rakefile
VERSION
ar_mailer_rails3.gemspec

README.rdoc

ar_mailer_rails3

A two-phase delivery agent for ActionMailer which works for Rails 3.

Forked from github.com/adzap/ar_mailer/

Rubyforge Project:

rubyforge.org/projects/seattlerb

Documentation:

seattlerb.org/ar_mailer

and for forked additions

github.com/yzhang/ar_mailer_rails3/wikis

Bugs:

github.com/yzhang/ar_mailer_rails3/issues

About

Even delivering 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.

Installing ar_mailer_rails3

Don't need remove adzap-ar_mailer or ar_mailer, just install ar_mailer_rails3

$ sudo gem install ar_mailer_rails3

Usage

Go to your Rails project:

$ cd your_rails_project

Create the migration, model and initializer:

This shows the options which are only the model name, which defaults to Email

./script/generate ar_mailer_rails3 -h

Then run with defaults

./script/generate ar_mailer email

Or specify a custom model name

./script/generate ar_mailer newsletter

See Alternate Mail Storage if you use a custom model name

In your mailer class methods you must be sure to set the From address for your emails. Something like:

def list_send(recipient)
  from 'no_reply@example.com'
  # ...

Edit config/initializer/ar_mailer_rails3.rb and uncomment below line to use ar_mailer as default delivery method:

ActionMailer::Base.delivery_method = :active_record

Or if you need to, you can set each mailer class delivery method individually:

class MyMailer < ActionMailer::Base
  self.delivery_method = :active_record
end

This can be useful when using plugins like ExceptionNotification. Where it might be foolish to tie the sending of the email alert to the database when the database might be causing the exception being raised. In this instance you could override ExceptionNofitier delivery method to be smtp or set the other mailer classes to use ARMailer explicitly.

Then to run it:

$ ar_sendmail_rails3

You can also run it from cron with -o, or as a daemon with -d.

See ar_sendmail_rails3 -h for full details.

Alternate Mail Storage

By default ar_mailer_rails3 assumes you are using an ActiveRecord model called Email to store the emails created before sending. If you want to change this you alter it in an intializer like so:

ActionMailer::Base.add_delivery_method :active_record, ArMailer::ActiveRecord, :email_class => Newsletter

A Word on TLS

If you are using Ruby >= 1.8.7, TLS will be enabled automatically if your SMTP server supports it. If you do not want it to automatically enabled then set the :tls option to false in your smtp_settings.

If you are on Ruby <= 1.8.6, then the TLS patch included in this plugin will be loaded, so you don't need another TLS plugin to add the capability. This patch allows you to explicit set if the server supports TLS by setting the :tls option to true in your smtp_settings.

Help

See ar_sendmail_rails3 -h for options to ar_sendmail_rails3.

NOTE: You may need to delete an smtp_tls.rb file if you have one lying around. ar_mailer supplies it own.

Run as a service (init.d/rc.d scripts)

For Linux both script and demo config files are in share/linux. See ar_sendmail.conf for setting up your config. Copy the ar_sendmail file to /etc/init.d/ and make it executable. Then for Debian based distros run 'sudo update-rc.d ar_sendmail defaults' and it should work. Make sure you have the config file /etc/ar_sendmail.conf in place before starting.

For FreeBSD or NetBSD script is share/bsd/ar_sendmail. This is old and does not support the config file unless someone wants to submit a patch.

Something went wrong with that request. Please try again.