Re: [Catalyst] Sending Email from Page?

2011-03-28 Thread John M. Dlugosz

On 3/27/2011 12:22 PM, Tomas Doran bobtfish-at-bobtfish.net |Catalyst/Allow to 
home| wrote:


And I would say that sending an email is a state change, and behavior of the application 
domain here.
That's a stretch, because you can argue that any side-effect is a change of state to the 
universe at large and there happens to be no accessor to read the results of the change.  
It clearly matches side effect, not state, unless you stretch the definition to make 
all side effects into state and lose all distinction.




An arbitrary helper subroutine used by the Controller is not a Model.  Since it is 
side-effect only, it matches one of the links in the graph (Controller TO Model) so it 
fits in the architecture provides the proper connectivity.  But that is a kludge, not 
its proper usage.


Again, I think that the sending of email from the application is _very much_ behavior. 
If behavior includes causing side effects, sure.  That is certainly something the 
Controller is allowed to do, and is the Controller's responsibility.



In future you may want to replace the implementation of it, or wrap it with extra 
functionality (e.g. to count the number of emails sent), or reuse it in an application 
context beyond the web app (e.g. sending email from a batch script).


So?  That is an argument for encapsulation and abstraction, not for making it a 
Model.



With a model all of these things are not only possible, they're easy, and you've got a 
framework for the abstraction and use outside Catalyst already provided...


I think we are in agreement that using the auto-discovery/loading, and the dissemination 
of settings, and whatever else a Catalyst component does for you, might be handy for 
writing helper code, as opposed to making it a plain Perl module.


But that doesn't make it a Model.  Saying it is (to promote auto-discovery and loading) 
is just a hack, done for that purpose only.


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-27 Thread Tomas Doran


On 22 Mar 2011, at 10:33, John M. Dlugosz wrote:

If Catalyst had something called an accessory that could draw upon  
the auto-discovery, loading, configuration, etc. of Components, but  
did not claim to be a model, I might agree.


Erm, why?

Why should it be called an 'accessory', rather than a 'model', what's  
the difference other than the nomanclature you want to use?


Cheers
t0m


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-27 Thread John M. Dlugosz

On 3/27/2011 2:24 AM, Tomas Doran bobtfish-at-bobtfish.net |Catalyst/Allow to 
home| wrote:


Erm, why?

Why should it be called an 'accessory', rather than a 'model', what's the difference 
other than the nomanclature you want to use?


Cheers
t0m


A view queries the model in order to generate an appropriate user interface

In M-V-C, and Model is fundamentally a source of information to be used by the 
View.

The *model* manages the behavior and data of the application domain, responds to requests 
for information about its state (usually from the view), and responds to instructions to 
change state (usually from the controller).


An arbitrary helper subroutine used by the Controller is not a Model.  Since it is 
side-effect only, it matches one of the links in the graph (Controller TO Model) so it 
fits in the architecture provides the proper connectivity.  But that is a kludge, not 
its proper usage.



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-27 Thread Tomas Doran


On 27 Mar 2011, at 16:30, John M. Dlugosz wrote:
The model manages the behavior and data of the application domain,  
responds to requests for information about its state (usually from  
the view), and responds to instructions to change state (usually  
from the controller).


Right.

And I would say that sending an email is a state change, and behavior  
of the application domain here.


An arbitrary helper subroutine used by the Controller is not a  
Model.  Since it is side-effect only, it matches one of the links in  
the graph (Controller TO Model) so it fits in the architecture  
provides the proper connectivity.  But that is a kludge, not its  
proper usage.


Again, I think that the sending of email from the application is _very  
much_ behavior. In future you may want to replace the implementation  
of it, or wrap it with extra functionality (e.g. to count the number  
of emails sent), or reuse it in an application context beyond the web  
app (e.g. sending email from a batch script).


With a model all of these things are not only possible, they're easy,  
and you've got a framework for the abstraction and use outside  
Catalyst already provided...


Cheers
t0m


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread Octavian Rasnita

From: John M. Dlugosz wxju46g...@snkmail.com
On 3/21/2011 2:41 PM, Octavian Rasnita orasnita-at-gmail.com 
|Catalyst/Allow to home| wrote:


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.


So don't tell them it wasn't sent; just drop it on the floor instead, 
because it would just confuse them?


I'm not expecting any errors once the deployment is shaken-out, but my 
feedback message states that it was not sent and suggests using the mailto 
link instead (and hyperlinks it within the message).  And the form is 
still shown filled out, so the person can copy/paste his content to a file 
to save, rather than losing it.




This is the job of a... job queue. It tries to send the message or execute 
another task you give it, and if it can't execute it, it marks it as 
not-executed and you will be able to see later the errors found. This way 
you can put it to try for more times to do that job automaticly.


But as I said, if you have the mail server running on the same server and if 
you just need to send a single message, you don't need a job queue. If you 
need to send thousands of messages after you have made a selection of the 
recipients from a database, it might take less time to insert a few 
thousands records in a database than to send those messages directly.


So sending the messages directly is not very scalable.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread Octavian Rasnita

From: John M. Dlugosz wxju46g...@snkmail.com
On 3/21/2011 2:47 PM, Octavian Rasnita orasnita-at-gmail.com 
|Catalyst/Allow to home| wrote:


If you use that key, the module won't report the error. If you don't use 
it and there will appear some errors, it will generate a detailed error. 
The error is generated by Email::Sender::Simple directly.


It will be something like unable to establish SMTP connection plus ~ 1 
kB of error trace.


I found it; thanks.  I started a discussion on PerlMonks because $@ was 
empty, even though letting the program die instead showed all the error 
info.  You must use Try::Tiny to try/catch around it.




I prefered to use send() or try_to_send() depending on the user's 
preference - if he wants or not to have the errors reported, but yes, using 
Try::Tiny may be a good alternative that should be investigated.


Octavian



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread 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: source_addr...@yoyo.com
to: whoe...@wherever.com
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.



- 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...

   


I don't buy it, see my former post. The Catalyst style does not say 
you should do everything through a Catalyst component. In fact, I find 
my way more elegant, since I don't have to think laterally in order to 
see that by using a Model I'm just sending an email. If I see a Model, I 
think of something like a data store, whatever the type. Sending an 
email is not like a data store, it's more like a communication device.


From the Catalyst Manual 
(http://search.cpan.org/~zarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual/About.pod#The_MVC_pattern 
http://search.cpan.org/%7Ezarquon/Catalyst-Manual-5.8005/lib/Catalyst/Manual/About.pod):


...
The purpose of the *Model* is to access and modify data. Typically the 
Model will interact with a relational database, but it's also common to 
use other data sources, such as the Xapian 
http://search.cpan.org/perldoc?Catalyst%3A%3AModel%3A%3AXapian search 
engine or an LDAP server.

...

I don't think sending an email is anything like accessing or modifying data.

But of course, this is perl. TIMTOWTDY. :-)

Regards
J.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread John M. Dlugosz
On 3/22/2011 3:07 AM, Jorge Gonzalez jorge.gonzalez-at-daikon.es |Catalyst/Allow to home| 
wrote:

...
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,
 );
...



Your sentiments echo my own.  Thanks for pointing out the config usage; I'll do 
that.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread Octavian Rasnita
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: source_addr...@yoyo.com
  to: whoe...@wherever.com
  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: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread John M. Dlugosz
If Catalyst had something called an accessory that could draw upon the auto-discovery, 
loading, configuration, etc. of Components, but did not claim to be a model, I might agree.


On 3/22/2011 4:42 AM, Octavian Rasnita orasnita-at-gmail.com |Catalyst/Allow to 
home| wrote:

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: source_addr...@yoyo.com
   to: whoe...@wherever.com
   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: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-22 Thread Octavian Rasnita
From: John M. Dlugosz 
  If Catalyst had something called an accessory that could draw upon the 
auto-discovery, loading, configuration, etc. of Components, but did not claim 
to be a model, I might agree.


  A model is not only a source of data, but also a destination of data.
  When sending email, some data is sent to a certain destination.

  However, I agree that some actions like sending email is not very appropriate 
for a view nor for a model, but for another kind of accessory with a more 
appropriate name as you said, but this is only because the words view or 
model are usually used for something else, so... it's just words.

  When we need to call a certain method in a controller we need to use 
$c-forward(), although it doesn't involve any forward or redirection, but 
again... there are just some words.

  Another advantage of using a model versus creating the object and using a 
mailer directly is that maybe after a certain time will appear a much better 
mailer than Mail::Builder::Simple, and you may want to switch to the new 
mailer. In that case you will need to make some changes in a single model, and 
not in every controller.

  Octavian
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Octavian Rasnita

From: John M. Dlugosz wxju46g...@snkmail.com
Any pointers as to the right (or best) way to send an email from my 
Catalyst App?
I see there is a Plugin::Email and also a View::Email, which seems to be 
something totally different?


You can use any of them or Catalyst::Helper::Model::Email. The plugin is no 
longer recommended.


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 free.
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.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread John M. Dlugosz

On 3/21/2011 1:48 AM, Octavian Rasnita orasnita-at-gmail.com |Catalyst/Allow to 
home| wrote:


You can use any of them or Catalyst::Helper::Model::Email. The plugin is no longer 
recommended.
So I see.  It's a simple wrapper that just integrates Catalyst config files, and that 
suits by purpose.  But trying to figure out how to use it I find the underlying stuff is 
deprecated.


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?





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 
free.
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?
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?


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Jorge Gonzalez
I really don't see the point in using an Email model. Just use the email 
sending module from the controller (Mail::Builder::Simple or whatever) 
and setup a local postfix which accepts outbound emails from local 
connections, and you're done. All queuing will be done by postfix, where 
it belongs.


You need to install a local mail server so that the Catalyst app does 
not get stuck trying to send. We can assume that messages sent from 
localhost will be handed over to the local MTA pretty quickly (besides 
corner cases like full mailspool and the like). This MTA can be a 
full-blown one, or one configured to use use a smart host.


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.

El 21/03/11 08:51, John M. Dlugosz escribió:
On 3/21/2011 1:48 AM, Octavian Rasnita orasnita-at-gmail.com 
|Catalyst/Allow to home| wrote:


You can use any of them or Catalyst::Helper::Model::Email. The plugin 
is no longer recommended.


It looks like helper just installs a dummy Model that calls 
Mail::Builder::Simple.  So I thought I'd just call that.  But, there 
is no documentation as to the return value, and the code appears to 
return 1 if it makes it to the end.  But what does it return on error, 
and where is the error particulars?



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/

Dev site: http://dev.catalyst.perl.org/



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Kutbuddin Doctor

Can someone post instructions for using postfix withing catalyst?

I have been seeing several (earlier) posts recommending Email::Sender.
I see instructions in Email::Sender for SMTP and sendmail, but no config 
options for postfix. I was only able to find Postfix mentioned in 
unrelated Perl modules (Mail::Postfix::Postdrop).


So if you have a local postfix running, how do you send an email to that 
service from within catalyst? I'm hoping the example will show how to 
setup connections to server in MyApp.pm and use it throughout the 
catalyst application.


thanks,
Kutbuddin

On 3/21/11 7:16 AM, Jorge Gonzalez wrote:

I really don't see the point in using an Email model. Just use the email
sending module from the controller (Mail::Builder::Simple or whatever)
and setup a local postfix which accepts outbound emails from local
connections, and you're done. All queuing will be done by postfix, where
it belongs.

You need to install a local mail server so that the Catalyst app does
not get stuck trying to send. We can assume that messages sent from
localhost will be handed over to the local MTA pretty quickly (besides
corner cases like full mailspool and the like). This MTA can be a
full-blown one, or one configured to use use a smart host.

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.

El 21/03/11 08:51, John M. Dlugosz escribió:

On 3/21/2011 1:48 AM, Octavian Rasnita orasnita-at-gmail.com
|Catalyst/Allow to home| wrote:

You can use any of them or Catalyst::Helper::Model::Email. The plugin
is no longer recommended.

It looks like helper just installs a dummy Model that calls
Mail::Builder::Simple.  So I thought I'd just call that.  But, there
is no documentation as to the return value, and the code appears to
return 1 if it makes it to the end.  But what does it return on error,
and where is the error particulars?


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/



--
Kutbuddin Doctor, PhD
Bioinformatics Shared Resource,
Sanford-Burnham Medical Research Institute
http://www.sanfordburnham.org/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Bill Moseley
On Sun, Mar 20, 2011 at 11:48 PM, Octavian Rasnita orasn...@gmail.comwrote:

 From: John M. Dlugosz wxju46g...@snkmail.com

  Any pointers as to the right (or best) way to send an email from my
 Catalyst App?
 I see there is a Plugin::Email and also a View::Email, which seems to be
 something totally different?


 You can use any of them or Catalyst::Helper::Model::Email. The plugin is no
 longer recommended.

 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 free.


That's good advice in general.  But, in a lot of ways mail, using a local
MTA, fits that role.



 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.
  Octavian



 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/




-- 
Bill Moseley
mose...@hank.org
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Peter Edwards
On 21 March 2011 16:45, Kutbuddin Doctor ksdoc...@sanfordburnham.orgwrote:

 Can someone post instructions for using postfix withing catalyst?

 I have been seeing several (earlier) posts recommending Email::Sender.
 I see instructions in Email::Sender for SMTP and sendmail, but no config
 options for postfix. I was only able to find Postfix mentioned in unrelated
 Perl modules (Mail::Postfix::Postdrop).


It's a Unix sysadmin task to set up Postfix (or another mail system [1]) ,
it's not really anything to do with Perl programming
http://www.postfix.org/docs.html

Once you have a mail server listening on localhost you can then send to it
using Email::Sender.

Regards, Peter
1. http://en.wikipedia.org/wiki/Comparison_of_mail_servers
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Octavian Rasnita
From: John M. Dlugosz wxju46g...@snkmail.com
 On 3/21/2011 1:48 AM, Octavian Rasnita orasnita-at-gmail.com |Catalyst/Allow 
 to home| wrote:

 You can use any of them or Catalyst::Helper::Model::Email. The plugin is no 
 longer 
 recommended.
 
 It looks like helper just installs a dummy Model that calls 
 Mail::Builder::Simple.  So I 
 thought I'd just call that.  But, there is no documentation as to the return 
 value, and 
 the code appears to return 1 if it makes it to the end.  But what does it 
 return on error, 
 and where is the error particulars?


In Mail::Builder::Simple you can find about live_on_error.

If you use that key, the module won't report the error. If you don't use it and 
there will appear some errors, it will generate a detailed error. The error is 
generated by Email::Sender::Simple directly.

It will be something like unable to establish SMTP connection plus ~ 1 kB of 
error trace.

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Octavian Rasnita
From: Jorge Gonzalez jorge.gonza...@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 = ['m...@myhost.com', 'My Name'],  #This line can be also defined in 
the configuration file and not here
to = 'someb...@anotherhost.net',
subject = 'The subject',
htmltext = 'h1Hello/h1 world',
attachment = $c-uri_for('/path/to/attachment.pdf'),
);

Octavian


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread Octavian Rasnita
From: John M. Dlugosz wxju46g...@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 
 free.
 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.

Octavian



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sending Email from Page?

2011-03-21 Thread John M. Dlugosz
On 3/21/2011 11:45 AM, Kutbuddin Doctor ksdoctor-at-sanfordburnham.org |Catalyst/Allow to 
home| wrote:

Can someone post instructions for using postfix withing catalyst?

I have been seeing several (earlier) posts recommending Email::Sender.
I see instructions in Email::Sender for SMTP and sendmail, but no config options for 
postfix. I was only able to find Postfix mentioned in unrelated Perl modules 
(Mail::Postfix::Postdrop).


So if you have a local postfix running, how do you send an email to that service from 
within catalyst? I'm hoping the example will show how to setup connections to server in 
MyApp.pm and use it throughout the catalyst application.


Nothing to it:  I just used the NMTP option in Sender or whatever fancier module defers to 
it (I'm usig Mail::Builder::Simple).  I think the default 'sendmail' would just call it, 
too.  If some mail server is running locally and listening to the usual ports, it should work!


For Postfix, the relevant option is

smtpd_recipient_restrictions= ... ,permit_mynetworks, ...

which allows it to accept mail from a server on the same machine without pestering for a 
password or client certificate or anything.


I also had to make sure the submitted email was just right, as my rules are rather 
picky.  The error messages are clear: need full From address, etc.


--John



___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/