[Catalyst] Sending Email from Page?
orasnita at gmail.com
Mon Mar 21 19:41:59 GMT 2011
From: "John M. Dlugosz" <wxju46gefd at snkmail.com>
> Reading the page for Catalyst::Helper::Model::Email, and assuming that a ')' keeps getting
> lost, it's just a simple to use but you look up an object via Model first. What is the
> benefit of that? I suppose you can have more than one configuration pre-set, but I don't
> see that happening. Is there some other advantage or conceptional purpose for making a
> "feature" or "content sink" or "side effect call" presented as a Model?
Yes you can define more email models, one for sending with Gmail, another one with your SMTP server and so on.
But the most important thing is that you can use the same configuration files and the same syntax for sending email from Catalyst and from a cron job.
Catalyst is just a glue and you can use Mail::Builder::Simple very easy in Catalyst directly.
Catalyst::Helper::Model::Email is helpful just because it allows you to use the configuration from your models or from the configuration file of your app and you can share that configuration among different Catalyst controllers and standalone programs which are ran as cron jobs.
(And if you need to send UTF-8 encoded messages, you also don't need to do the encoding nor to create the MIME headers yourself.)
>> The most simple way is not the best. The best way is to send the messages in a job queue
>> and let the worker module to send the message immediately or whenever the mail server is
>> If you send the message directly from your application, in that moment the server might
>> not be free and the user would need to wait too much until the message is sent, or the
>> mail server might give a timeout and in that case the message is lost because the
>> application doesn't send it again when the mail server is free.
> I like being able to get a return result so I know it was sent!
> If that is not possible on a real server, is there some module already that does this?
If you want this, it is more simple, because you can try to send the message directly, but if the message is not sent, your page visitors will be able to read that a certain message was not sent, but they won't be able to do anything to send it, unless they try again, by filling again a subscription form or something like that.
> Hmm, maybe it depends on the mailer used? Postfix just queues the incoming message
> anyway! Why am I needing to duplicate what it already does? Would another queue process
> in front of it be less likely to get stuck?
If the mail server is running locally, not on another server, and if you are sure that it runs fine, then you don't need a job queue.
More information about the Catalyst