[Catalyst] Sending Email from Page?
Octavian Rasnita
orasnita at gmail.com
Mon Mar 21 19:58:38 GMT 2011
From: "Jorge Gonzalez" <jorge.gonzalez at daikon.es>
> Catalyst offers you some posibilities, but it does not force you to use
> them. To me, using a model for sending email is like hammering a nail
> with a screw driver. You can surely do it, but it's simpler to use the
> hammer. Even if you have a fancy screw driver. :-)
>
> Regards
> J.
Yes, it is very simple to use Mail::Builder::Simple directly, but there are some advantages when using it in a model:
- You can share the configuration data among more controllers and even external programs;
- You need to write less code in your controllers;
- It is more elegant, because it uses the Catalyst style - you don't need to "use Mail::Builder::Simple" in every controller in which you need to send mail...
You can send email by just using:
$c->model( 'Email' )->send(
from => ['me at myhost.com', 'My Name'], #This line can be also defined in the configuration file and not here
to => 'somebody at anotherhost.net',
subject => 'The subject',
htmltext => '<h1>Hello</h1> world',
attachment => $c->uri_for('/path/to/attachment.pdf'),
);
Octavian
More information about the Catalyst
mailing list