App::Framework::Feature::Mail - Send mail
use App::Framework '+Mail' ;
Provides a simplified mail interface, and application error auto-mailing.
When used as a mail interface, this feature is accessed in the same manner as any other (e.g. see App::Framework::Feature::Args).
The accessor function ("mail") returns the mail object if no parameters are specified; otherwise it will send a mail:
$app->Mail("This is a test", 'from' => 'someone@domain.co.uk', 'to' => 'afriend@domain.com', 'subject' => 'a test', ) ;
Default settings may be set at the start of an application so that only specific parameters need to be added:
$app->Mail()->set( 'from' => 'someone@domain.co.uk', 'error_to' => 'someone@domain.co.uk', 'err_level' => 'warning', ) ; ## send a mail to 'afriend@domain.com' $app->Mail("This is a test", 'to' => 'afriend@domain.com', 'subject' => 'a test', ) ; ... ## send another - still goers to 'afriend@domain.com' $app->Mail("This is another test", 'subject' => 'another test', ) ;
An additional capability is that this feature can automatically send emails of any errors. To do this you first of all need to specify the 'error_to' recipient, and then set the 'err_level'. The 'err_level' setting specifies the type of error that will generate an email. For example, setting 'err_level' to "warning" means all warnings AND errors will result in emails; but notes will not (see App::Framework::Base::Object::ErrorHandle for types).
This feature also automatically adds mail-related command line options to allow a user to specify the field settings for themselves (or an application may over ride with their own defaults).
Note that the 'to' and 'error_to' fields may be a comma seperated list of mail recipients.
This extension adds the following additional command line options to any application:
Email sender
Email recipient. Where there are multiple recipients, they should be set as a comma seperated list of email addresses
Email recipient for errors. If set, program errors are sent to this email.
Set the minium error level that triggers an email. Level can be: note, warning, error
Optional mail subject line
Mailing host. If not specified uses 'localhost'
The following fields should be defined either in the call to 'new()', as part of a 'set()' call, or called by their accessor method (which is the same name as the field):
Create a new Mail.
The %args are specified as they would be in the set method (see "Fields").
Initialises the Mail object class variables.
Send some mail stored in $content. $content may either be a string (containing newlines), or an ARRAY ref.
Optionally %args may be specified (to set 'subject' etc).
If no arguments are specified then just returns the mail object.
Alias to "mail"
Called by the application framework at the start of the application.
This method checks for the user specifying any of the options described above (see "ADDITIONAL COMMAND LINE OPTIONS") and handles them if so.
Optionally %args may be specified (to set 'subject' etc)
Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.
Steve Price <sdprice at cpan.org>
<sdprice at cpan.org>
None that I know of!
To install App::Framework, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Framework
CPAN shell
perl -MCPAN -e shell install App::Framework
For more information on module installation, please visit the detailed CPAN module installation guide.