> >   Yeah I've seen some neat twisted stuff, POE might be a reasonable
> >   alternative in the Perl space.
> 
> POE is pretty neat.  I haven't played with it much, but i liked it.
> 
> I've done a lot of twisted stuff in the past , so its very natural to  
> me.  I brought it up over POE though  , because it ships with an smtp  
> server built in - you really just need to customize the callbacks,  
> and you're good to go.

I don't know twisted or POE, but the way I handle it is this:

 - my mod_perl app inserts a row into my 'mail' table, with the name
   of the mail to be sent, the recipient, and any relevant data

 - I have a cron daemon in perl, which I've written using Schedule::Cron
   which loads all the relevant modules that I need.

 - It fires a job every minute, looks at the mail queue, and uses the
   local sendmail to inject the mail into the local mail queue, and 
   marks the mail as sent

Advantages:

 - my mod_perl process can return immediately

 - the cron daemon can run on any machine, doesn't have to be a 
   webserver.

 - the SMTP server I use (postfix) does just SMTP and does it well,
   so I don't need to think about networking issues

 - I have full access to all my perl objects within the cron daemon,
   and, like mod_perl, the code is all preloaded, so that forking the
   new job is quick. If a particular job needs some memory hogging 
   modules eg PDF2::API, I require those only in that job, so that
   the memory gets released as soon as the job is complete

Disadvantage:

 - you can wait for up to a minute before the mail gets processed. 
   Although, with Schedule::Cron, you can schedule jobs every second

Clint

Reply via email to