[Catalyst] Sending email from Catalyst and scripts

Chisel Wright chisel at herlpacker.co.uk
Tue May 22 22:31:31 GMT 2007


On Tue, May 22, 2007 at 11:10:58AM -0700, Evaldas Imbrasas wrote:
> I'm looking for best practices for sending email from the catalyst app
> that would also work with command-line scripts (cronjobs, one-time
> scripts, etc.).

Personally I use a database table as a crude email queue. I should
probably use an MTA, but I don't.

The table is pretty simple; id, queued_time, recipient, cc, bcc, sender,
subject, text_content, html_content.
Obviously you can move the recipient, etc out into join tables, etc if
you want, but this suits my needs.

Then my application can dump emails there, in fact anything can if it
wishes.
The application uses the ->render() method on a view that doesn't
automatically include header.tt and footer.tt from the application
itself. (MyApp::View::Plain vs MyApp::View::TT - both use TT, they're
just configured differently)

While I'm developing, no emails get sent, and I poke the db to double
check things. From time to time I'll run a simple daemon that picks up
emails, builds and delivers them (using MIME::Lite).


I don't like sending emails directly from controller actions. I'm
worried about things taking a long time, no idea what's gone through the
system, and so on.


-- 
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

  If you were MEANT to understand it, we wouldn't have called it 'code'



More information about the Catalyst mailing list