From: Jorge Gonzalez 
  El 21/03/11 20:58, Octavian Rasnita escribió: 
    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 can do it also without the model. Just create a new section in the 
application config file:

  (YAML):

  ...
  Mail:
      from: [email protected]
      to: [email protected]
      subject: Hello
  ...

  And then from the controller:

  ...
  my $mail = Mail::Builder::Simple->new;
  $mail->send(
    from => MyApp->config->{Mail}{from},
    to => MyApp->config->{Mail}{to},
    subject => MyApp->config->{Mail}{subject},,
    plaintext => "Hello,\n\nHow are you?\n",
   );
  ...

- You need to write less code in your controllers;

As we can see by the above example, it's more or less the same amount of code. 
In this example yes, you are right, because Mail::Builder::Simple requires very 
few lines of code in any case, but if the mail sender is SMTP and needs to 
specify the host name, possibily the port if it is not a common one, the 
username and the password if it requires authentication, and also specify if it 
uses SSL... then it would be more simple to use a model to access 
Mail::Builder::Simple. The model is very thin anyway. But as you said... 
TIMTOWTDI. Octavian
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to