|
NAMEEmail::Send - Simply Sending EmailWAIT! ACHTUNG!Email::Send is going away... well, not really going away, but it's being officially marked "out of favor." It has API design problems that make it hard to usefully extend and rather than try to deprecate features and slowly ease in a new interface, we've released Email::Sender which fixes these problems and others. As of today, 2008-12-19, Email::Sender is young, but it's fairly well-tested. Please consider using it instead for any new work.SYNOPSISuse Email::Send; my $message = <<'__MESSAGE__'; To: recipient@example.com From: sender@example.com Subject: Hello there folks How are you? Enjoy! __MESSAGE__ my $sender = Email::Send->new({mailer => 'SMTP'}); $sender->mailer_args([Host => 'smtp.example.com']); $sender->send($message); # more complex my $bulk = Email::Send->new; for ( qw[SMTP Sendmail Qmail] ) { $bulk->mailer($_) and last if $bulk->mailer_available($_); } $bulk->message_modifier(sub { my ($sender, $message, $to) = @_; $message->header_set(To => qq[$to\@geeknest.com]) }); my @to = qw[casey chastity evelina casey_jr marshall]; my $rv = $bulk->send($message, $_) for @to; DESCRIPTIONThis module provides a very simple, very clean, very specific interface to multiple Email mailers. The goal of this software is to be small and simple, easy to use, and easy to extend.Constructors
Properties
METHODS
Writing Mailerspackage Email::Send::Example; sub is_available { eval { use Net::Example } } sub send { my ($class, $message, @args) = @_; use Net::Example; Net::Example->do_it($message) or return; } 1; Writing new mailers is very simple. If you want to use a short name when calling "send", name your mailer under the "Email::Send" namespace. If you don't, the full name will have to be used. A mailer only needs to implement a single function, "send". It will be called from "Email::Send" exactly like this. Your::Sending::Package->send($message, @args); $message is an Email::Simple object, @args are the extra arguments passed into "Email::Send::send". Here's an example of a mailer that sends email to a URL. package Email::Send::HTTP::Post; use strict; use vars qw[$AGENT $URL $FIELD]; use Return::Value; sub is_available { eval { use LWP::UserAgent } } sub send { my ($class, $message, @args); require LWP::UserAgent; if ( @args ) { my ($URL, $FIELD) = @args; $AGENT = LWP::UserAgent->new; } return failure "Can't send to URL if no URL and field are named" unless $URL && $FIELD; $AGENT->post($URL => { $FIELD => $message->as_string }); return success; } 1; This example will keep a UserAgent singleton unless new arguments are passed to "send". It is used by calling "Email::Send::send". my $sender = Email::Send->new({ mailer => 'HTTP::Post' }); $sender->mailer_args([ 'http://example.com/incoming', 'message' ]); $sender->send($message); $sender->send($message2); # uses saved $URL and $FIELD SEE ALSOEmail::Simple, Email::Abstract, Email::Send::IO, Email::Send::NNTP, Email::Send::Qmail, Email::Send::SMTP, Email::Send::Sendmail, perl.PERL EMAIL PROJECTThis module is maintained by the Perl Email Project.<http://emailproject.perl.org/wiki/Email::Send> AUTHORCurrent maintainer: Ricardo SIGNES, <rjbs@cpan.org>.Original author: Casey West, <casey@geeknest.com>. COPYRIGHTCopyright (c) 2005 Casey West. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |