= ar_mailer

A two-phase delivery agent for ActionMailer.

This fork allows you to add some context to the ar_mailer log, i.e. you can track "lost emails" such that when a customer complains of a missing email, you are able to find out what "identifier" in your system became what SMTP message-id, and continue tracking to the SMTP server logs.

This fork also logs in its own log file rather than using the Rails logger.

This fork is based on the fork by adzap (http://github.com/adzap/ar_mailer/tree/master) and includes the connectivity patches from gefilte (http://github.com/gefilte/ar_mailer/tree/master)

Rubyforge Project:

http://rubyforge.org/projects/seattlerb

Documentation:

http://seattlerb.org/ar_mailer

and for forked additions

http://github.com/adzap/ar_mailer/wikis

Bugs:

http://rubyforge.org/tracker/?func=add&group_id=1513&atid=5921

== 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 (forked)

Install the gem from GitHub gems server:

First, if you haven't already

$ sudo gem sources -a http://gems.github.com

Then

$ sudo gem install zendesk-ar_mailer

See ActionMailer::ARMailer for instructions on converting to ARMailer.

See ar_sendmail -h for options to ar_sendmail.

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

=== Getting context aware logging (this fork)

If you want to log some extra information that you can use to tie a specific send email to
something in your application, do this:

1. Add a +context+ column to your emails table, eg.:

add_column :emails, :context, :string

2. Set the information you want ar_sendmail to log alongside the message-id in your mailer class:

headers('X-Delivery-Context' => 'Hello there')

This will print 'Hello there' in the line that also contains the message-id of the sent email, like so:

ar_sendmail Fri Oct 17 12:04:58 +0000 2008: sent email 00000579421 [Hello there] from [email protected] to [email protected]: "250 OK id=1Kqo4g-0006Nx-MP\n"

=== 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.

Alternatively, use a monitoring solution like monit or god, or google: cron @reboot