diff options
| author | fukachan <fukachan> | 2001-01-19 13:55:05 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-19 13:55:05 +0000 |
| commit | d63380e790c2f93ae981a0425b85d22601c1acaa (patch) | |
| tree | 255ceabf69b7a95c02f3a648ddf4c194f66eeb3b /cpan/lib/Mail/Send.pm | |
| parent | 4377641665acbf1a4a83883241afe392e88ec112 (diff) | |
| download | fml8-d63380e790c2f93ae981a0425b85d22601c1acaa.tar.gz fml8-d63380e790c2f93ae981a0425b85d22601c1acaa.tar.bz2 fml8-d63380e790c2f93ae981a0425b85d22601c1acaa.zip | |
Initial revision
Diffstat (limited to 'cpan/lib/Mail/Send.pm')
| -rw-r--r-- | cpan/lib/Mail/Send.pm | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/cpan/lib/Mail/Send.pm b/cpan/lib/Mail/Send.pm new file mode 100644 index 00000000..346a2002 --- /dev/null +++ b/cpan/lib/Mail/Send.pm @@ -0,0 +1,110 @@ + +package Mail::Send; + +# $Id$ + +use strict; +use Carp; +use vars qw($VERSION); +require Mail::Mailer; + +$VERSION = "1.09"; + +sub Version { $VERSION } + +sub new { + my $pkg = shift; + my %attr = @_; + my($key, $value); + my $me = bless {}, $pkg; + while( ($key, $value) = each %attr ) { + $key = lc($key); + $me->$key($value); + } + $me; +} + +sub set { + my($me, $hdr, @values) = @_; + $me->{$hdr} = [ @values ] if @values; + @{$me->{$hdr} || []}; # return new (or original) values +} + +sub add { + my($me, $hdr, @values) = @_; + $me->{$hdr} = [] unless $me->{$hdr}; + push(@{$me->{$hdr}}, @values); +} + +sub delete { + my($me, $hdr) = @_; + delete $me->{$hdr}; +} + +sub to { my $me=shift; $me->set('To', @_); } +sub cc { my $me=shift; $me->set('Cc', @_); } +sub bcc { my $me=shift; $me->set('Bcc', @_); } +sub subject { my $me=shift; $me->set('Subject', join (' ', @_)); } + + +sub open { + my $me = shift; + Mail::Mailer->new(@_)->open($me); +} + +1; + +__END__ + +=head1 NAME + +Mail::Send - Simple electronic mail interface + +=head1 SYNOPSIS + + require Mail::Send; + + $msg = new Mail::Send; + + $msg = new Mail::Send Subject=>'example subject', To=>'timbo'; + + $msg->to('user@host'); + $msg->subject('example subject'); + $msg->cc('user@host'); + $msg->bcc('someone@else'); + + $msg->set($header, @values); + $msg->add($header, @values); + $msg->delete($header); + + # Launch mailer and set headers. The filehandle returned + # by open() is an instance of the Mail::Mailer class. + + $fh = $msg->open; + + print $fh "Body of message"; + + $fh->close; # complete the message and send it + + $fh->cancel; # not yet implemented + +=head1 DESCRIPTION + +=head1 SEE ALSO + +Mail::Mailer + +=head1 AUTHORS + +Maintained by Graham Barr E<lt>F<gbarr@pobox.com>E<gt> + +Original code written by Tim Bunce E<lt>F<Tim.Bunce@ig.co.uk>E<gt>, +with a kick start from Graham Barr E<lt>F<gbarr@pobox.com>E<gt>. With +contributions by Gerard Hickey E<lt>F<hickey@ctron.com>E<gt> + +For support please contact comp.lang.perl.misc or Graham Barr +E<lt>F<gbarr@pobox.com>E<gt> + +=cut + + |
