package Email::Sender::Transport::IM2000; use Mouse; extends 'Email::Sender::Transport';
sub send_email { my ($self, $email, $env) = @_; print $email->as_string; return $self->success; }
...
my $xport = Email::Sender::Transport::IM2000->new; $xport->send($email, { to => [ $recipient, ... ], from => $from });
Email::Sender::Transport is the base class for mail-sending classes in the Email::Sender system.
There are only three critical things to know about using an Email::Sender transport:
Some transports will either succeed or fail totally. Some also allow partial success to be signalled. Others (like LMTP) may require that partial success be accounted for.
Partial success is indicated by the return of a the Email::Sender::Success::Partial manpage. The most commonly useful network transports, Sendmail and SMTP, will never return a partial success in their default configuration, so most users can avoid worrying about them.
my $result = eval { $sender->send($email, \%env) };
This is the only method that most users will ever need to call. It attempts to send the message across the transport, and will either return success or raise an exception.
This method is called by send, which should probably not be overriden.
Instead, override this method. It is passed an the Email::Abstract manpage object and
an envelope. The envelope is a hashref in the following form:
to - an arrayref of email addresses (strings) from - a single email address (string)
It should either return success or throw an exception (preferably one that is an Email::Sender::Failure).
This method is passed a scalar and is expected to return an Email::Abstract object. You probably shouldn't override it in most cases.
This method is passed a hashref and returns a new hashref that should be used
as the envelope passed to the send_email method. This method is responsible
for ensuring that the to entry is an array.
... return $self->success;
This method returns a new Email::Sender::Success object. Arguments passed to
this method are passed along to the Success's constructor. This is provided as
a convenience for returning success from subclasses' send_email methods.
Ricardo SIGNES, <rjbs@cpan.org>
Please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Copyright 2006-2008, Ricardo SIGNES.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.