[Catalyst] Sending email from Catalyst and scripts

Mark Zealey mark at itsolve.co.uk
Wed May 23 07:41:21 GMT 2007


Why can you not do something like $c->stash->{emails_to_send} and then just 
fire them off in the end() action after the page has been returned to the 
remote browser?

M


On Tuesday 22 May 2007 10:31 pm, Chisel Wright wrote:
> 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.



More information about the Catalyst mailing list