NAME
Email::Sender::Server::Client - Email Delivery Agent
VERSION
version 0.28
SYNOPSIS
# sending email is simple
use Email::Sender::Server::Client 'mail';
my @message = (
to => '...',
subject => '...',
body => '...',
);
my ($client) = mail @message;
if ($client->error_count) {
die $client->errors_to_string;
}
my ($client, $msg_id) = mail @message;
unless ($msg_id) {
die $client->errors_to_string;
}
or using an object-oriented approach ....
use Email::Sender::Server::Client;
my $client = Email::Sender::Server::Client->new;
my @message = (to => '...', subject => '...', body => '...');
my $msg_id = $client->send(@message);
if ($client->error_count) {
print $client->errors_to_string;
}
altering or using a non-sendmail transport ...
use Email::Sender::Server::Client;
my $client = Email::Sender::Server::Client->new;
my @message = (to => '...', subject => '...', body => '...');
push @message, 'transport' => {
# key is the Email::Sender transport driver,
# value is the transport driver's arguments
STMP => {
host => '...',
port => '...',
}
};
my ($msg_id) = $client->send(@message);
unless ($msg_id) {
print $client->errors_to_string;
}
Please see the Email::Sender::Server::Message class for attributes that can be used as arguments to the mail() and send() methods.
Currently all ESS classes operate out of the current-working-directory which can be sub-optimal, especially when used in other classes that can be utilized by various different scripts.
The ESS_DATA environment variable can be set to change the path of the ess_data (data) directory utilized by the ess program, otherwise you may use the path parameter.
By default, a "ess_data" folder is created for you automatically in the current directory however when changing the path to the ess_data directory, please note that such a change will supercede the defaults and data will be stored at the path you've specified. For continuity, try to use absolute paths only!!!
use Email::Sender::Server::Client 'mail';
# if you need to change the ess data directory
push @message, path => '/path/to/ess/parent/folder' ;
my ($client) = mail @message;
DESCRIPTION
Email::Sender::Server::Client provides an interface to the ESS non-blocking email delivery system which queues emails for later delivery. This class is a simple wrapper around the Email::Sender::Server::Manager class, the manager is responsible for queuing email messages and delegating tasks to the worker processes. Note, All messages are validated by Email::Sender::Server::Message.
EXPORTS
The mail method is designed to provide a simple single method for sending emails to the server. It accepts valid attributes accepted by Email::Sender::Server::Message. It returns a list of two elements, a client object and the filepath of the queued message if the operation was successful.
use Email::Sender::Server::Client 'mail';
my @message = (
to => '...',
subject => '...',
body => '...',
);
my ($client, $msg_id) = mail @message;
unless ($msg_id) {
die $client->errors_to_string;
}
METHODS
send
The send method is designed to provide an object-oriented approach for sending emails to the server. It accepts all valid attributes accepted by Email::Sender::Server::Message. It returns a the filepath of the queued message if the operation was successful.
use Email::Sender::Server::Client;
my $client = Email::Sender::Server::Client->new;
my @message = (to => '...', subject => '...', body => '...');
my $msg_id = $client->send(@message);
if ($client->error_count) {
print $client->errors_to_string;
}
AUTHOR
Al Newkirk <awncorp@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by awncorp.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.