NAME
XAS::System::Email - The Email module for the XAS environment
SYNOPSIS
Your program can use this module in the following fashion:
use XAS::System;
$email = XAS::System->module('email');
$email->send(
-from => "me\@localhost",
-to => "dba\@wsipc.org",
-subject => "Testing",
-message => "This is a test"
);
or ...
use XAS::System;
my $xas = XAS::System->module('environment');
my $email = XAS::System->module(
email => {
-mailer => 'smtp',
-server => 'relay.wsipc.org'
}
);
my $from = 'sysadm' . '@' . $xas->hostname . $xas->domain;
$email->send(
-from => $from,
-to => "dba\@wsipc.org",
-subject => "Testing",
-message => "This is a test"
);
DESCRIPTION
This is the the module for sending email within the XAS environment.
METHODS
new
This method initializes the module. It is automatically called when invoked by XAS::System->module(). It takes the following parameters:
- -server
-
The default is mail.example.com. This default can changed with the environment variable MXSERVER. It can also be changed with the named parameter -server upon load or the server() method after loading.
- -port
-
The default is 25. This default can be changed with the environment variable MXPORT. It can also be changed with the named parameter -port upon load or the port() method after loading.
- -mailer
-
This defines how the email is sent. There are two ways to send email they are a direct connection using smtp or queue the mail for transmittial using sendmail. The default is "smtp". This can be changed to "sendmail" with the named parameter -mailer upon load or the mailer() method after loading.
- -timeout
-
This sets the timeout used for sending email. The default is 60 seconds. This can be changed with the named parameter -timeout upon load or the timeout() method after loading.
send
This method will send an email. It takes the following named parameters:
- -to
-
The SMTP address of the receipent.
- -from
-
The SMTP adderss of the sender.
- -subject
-
A subject line for the message.
- -message
-
The text of the message.
- -attachment
-
A filename to append to the message.
MUTATORS
mailer
This method will set/return the current mailer.
Example
$mailer = $email->mailer;
$email->mailer('sendmail');
timeout
This method will set/return the current timeout value for mail processing.
Example
$timeout = $email->timeout;
$email->timeout('60');
server
This method will set/return the current mxserver value for mail processing.
Example
$server = $email->server;
$email->server('relay.wsipc.org');
port
This method will set/return the current mxport value for mail processing.
Example
$port = $email->port;
$email->port('25');
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Kevin L. Esteb
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.