[Catalyst] Sending email safely with Catalyst

Pedro Melo melo at simplicidade.org
Fri Apr 11 17:42:08 BST 2008


Hi,

On Apr 11, 2008, at 4:15 PM, Zbigniew Lukasiak wrote:
> On Fri, Apr 11, 2008 at 4:49 PM, J. Shirley <jshirley at gmail.com>  
> wrote:
>>
>> On Fri, Apr 11, 2008 at 3:51 AM, Zbigniew Lukasiak  
>> <zzbbyy at gmail.com> wrote:
>>> On Fri, Apr 11, 2008 at 11:42 AM, Paul Makepeace  
>>> <paulm at paulm.com> wrote:
>>>> I see there's an Email plugin and wondered if this is enough to  
>>>> send
>>>>  email from a form safely & securely or whether something more  
>>>> involved
>>>>  like a port of NMS CGI exists?
>>>>
>>>>  http://search.cpan.org/~mramberg/Catalyst-Plugin-Email-0.08/ 
>>>> Email.pm
>>>>  http://nms-cgi.sourceforge.net/
>>>>
>>>>  It's terribly easy to get this wrong so wanted some feedback from
>>>>  people who'd previously implemented something like this live  
>>>> before
>>>>  inadvertently turning my site into a spam conduit :-)
>>>
>>>
>>>  I've got a related question - does anyone send bulk emails with  
>>> that
>>>  plugin?  Is the delay reasonable when sending let's say a hundred
>>>  emails or do I need a background mechanism for that?  I have now a
>>>  forking solution - but it is a bit complex (and for mod_perl they
>>>  recommend to do it in a 'cleanup' handler instead of a forked
>>>  process).
>>>
>>>
>>
>>  I've been dying to play with
>>  http://search.cpan.org/~btrott/Email-Send-TheSchwartz-0.01/lib/ 
>> Email/Send/TheSchwartz.pm

I use this exactly to send email.

My worker gets the MX of the destination domain and sends the email  
directly to the remote server. This allows me to react more quickly  
to invalid email addresses (for those servers that check RCPT TO's).


> This is interesting - but the documentation unfortunately does not
> answer following questions:
>
> - The worker looks like a polling daemon - how often does it poll the
> database?  Would it be feasible solution on an SQLite database (which
> does not work very well with many concurrent connections).

5 seconds by default. You can override it in the call to work(). It's  
documented btw.


> - How should I run the worker process so that it does not die
> unexpectedly?  Should I put it into inittab or perhaps should I run it
> in a pair of processes that would fork another one if one of them
> dies?

Some people use daemontools, other initab, or ruinit.... There are  
several systems to do that.

Alternatively you could just run from cron and use the work_once()  
call, or the work_until_done(), more difficult to predict the load  
though.

Best regards,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo at simplicidade.org
Use XMPP!





More information about the Catalyst mailing list