Email::Sender::Server::Manager - Email Server Manager
version 0.40
use Email::Sender::Server::Manager; my $manager = Email::Sender::Server::Manager->new; # create a list of Email::Sender::Server::Message attribute values my @message = ( to => '...', subject => '...', body => '...', ); # validate and record an email message $manager->create_work(@message); # delegate and process email messages $manager->process_workload; # blocking
Email::Sender::Server::Manager is responsible for communicating messages between the client, server and workers. Specifically, this class is responsible for queuing and assigning email requests to worker processes for eventual delivery.
See Email::Sender::Server::Worker for more information about that process.
The spawn attribute represents the number of workers to create when processing the email queue. This attribute defaults to 3 (worker processes).
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new( spawn => 10 );
The workers attribute contains an arrayref of worker process IDs. This value is empty by default and is set internally by the process_workload() method.
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; $mgr->workers;
The workspace attribute contains the directory path to the queued ess_data directory.
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; $mgr->workspace;
The cleanup method restores the data directory to its initial state, re-queuing any emails assigned to workers which haven't been processed yet.
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; $mgr->cleanup;
The create_config method writes a config file to the data directory unless one exists. The config, if present, will be merge with Email::Sender::Server::Message attributes when messages are created (e.g. the create_work method).
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; $mgr->create_config;
... which creates a config file (e.g. in ./ess_data/config) containing:
$VAR1 = { message { to => '...', from => '...', }, transport => { SMTP => { host => '...', port => '...' } } };
... elsewhere in your codebase
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; # to, from, and transport taken from the config if not set $mgr->create_work(subject => '...', text => '...');
The create_work method writes a message file to the data directory queuing it to be process by the next selected worker process. It returns the absolute path to the queued email message unless message validation failed.
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; my @message = ( to => '...', subject => '...', body => '...', ); my $filepath = $mgr->create_work(@message); unless ($filepath) { print $mgr->errors_to_string; }
The delegate_workload method creates a number of worker processes based on the spawn attribute, forks itself and blocks until shutdown.
use Email::Sender::Server::Manager; my $mgr = Email::Sender::Server::Manager->new; $mgr->delegate_workload; # blocking
Al Newkirk <awncorp@cpan.org>
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.
To install Email::Sender::Server, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Email::Sender::Server
CPAN shell
perl -MCPAN -e shell install Email::Sender::Server
For more information on module installation, please visit the detailed CPAN module installation guide.