Mail-Transport-3.002/0000755000175000001440000000000013232117764015116 5ustar00markovusers00000000000000Mail-Transport-3.002/lib/0000755000175000001440000000000013232117764015664 5ustar00markovusers00000000000000Mail-Transport-3.002/lib/Mail/0000755000175000001440000000000013232117764016546 5ustar00markovusers00000000000000Mail-Transport-3.002/lib/Mail/Transport/0000755000175000001440000000000013232117764020542 5ustar00markovusers00000000000000Mail-Transport-3.002/lib/Mail/Transport/Exim.pod0000644000175000001440000001426213232117764022155 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Exim - transmit messages using external Exim program =head1 INHERITANCE Mail::Transport::Exim is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $sender = Mail::Transport::Exim->new(...); $sender->send($message); =head1 DESCRIPTION Implements mail transport using the external C<'Exim'> program. When instantiated, the mailer will look for the binary in specific system directories, and the first version found is taken. Extends L<"DESCRIPTION" in Mail::Transport::Send|Mail::Transport::Send/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Send|Mail::Transport::Send/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Send|Mail::Transport::Send/"Constructors">. =over 4 =item Mail::Transport::Exim-EB(%options) If you have Exim installed in a non-standard location, you will need to specify the path, using L. -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' username Mail::Transport undef via Mail::Transport 'exim' =over 2 =item executable => FILENAME =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item timeout => SECONDS =item trace => LEVEL =item username => STRING =item via => CLASS|NAME =back =back =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Inherited, see L =item $obj-EB($message, $fh, %options) Inherited, see L =item $obj-EB($message, %options) Inherited, see L =item $obj-EB($message, %options) =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Send|Mail::Transport::Send/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Send|Mail::Transport::Send/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Exim-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Exim-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Exim-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Send|Mail::Transport::Send/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Error: Errors when closing Exim mailer $program: $! The Exim mail transfer agent did start, but was not able to handle the message correctly. =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/SMTP.pm0000644000175000001440000001156313232117763021670 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::SMTP; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport::Send'; use strict; use warnings; use Net::SMTP; sub init($) { my ($self, $args) = @_; my $hosts = $args->{hostname}; unless($hosts) { require Net::Config; $hosts = $Net::Config::NetConfig{smtp_hosts}; undef $hosts unless @$hosts; $args->{hostname} = $hosts; } $args->{via} ||= 'smtp'; $args->{port} ||= '25'; $self->SUPER::init($args) or return; my $helo = $args->{helo} || eval { require Net::Config; $Net::Config::inet_domain } || eval { require Net::Domain; Net::Domain::hostfqdn() }; $self->{MTS_net_smtp_opts} = +{ Hello => $helo , Debug => ($args->{smtp_debug} || 0) }; $self->{MTS_esmtp_options} = $args->{esmtp_options}; $self->{MTS_from} = $args->{from}; $self; } sub trySend($@) { my ($self, $message, %args) = @_; my %send_options = ( %{$self->{MTS_esmtp_options} || {}} , %{$args{esmtp_options} || {}} ); # From whom is this message. my $from = $args{from} || $self->{MTS_from} || $message->sender || '<>'; $from = $from->address if ref $from && $from->isa('Mail::Address'); # Who are the destinations. if(defined $args{To}) { $self->log(WARNING => "Use option `to' to overrule the destination: `To' would refer to a field"); } my @to = map {$_->address} $self->destinations($message, $args{to}); unless(@to) { $self->log(NOTICE => 'No addresses found to send the message to, no connection made'); return 1; } # Prepare the header my @header; require IO::Lines; my $lines = IO::Lines->new(\@header); $message->head->printUndisclosed($lines); # # Send # if(wantarray) { # In LIST context my $server; return (0, 500, "Connection Failed", "CONNECT", 0) unless $server = $self->contactAnyServer; return (0, $server->code, $server->message, 'FROM', $server->quit) unless $server->mail($from, %send_options); foreach (@to) { next if $server->to($_); # must we be able to disable this? # next if $args{ignore_erroneous_destinations} return (0, $server->code, $server->message,"To $_",$server->quit); } $server->data; $server->datasend($_) foreach @header; my $bodydata = $message->body->file; if(ref $bodydata eq 'GLOB') { $server->datasend($_) while <$bodydata> } else { while(my $l = $bodydata->getline) { $server->datasend($l) } } return (0, $server->code, $server->message, 'DATA', $server->quit) unless $server->dataend; return ($server->quit, $server->code, $server->message, 'QUIT', $server->code); } # in SCALAR context my $server; return 0 unless $server = $self->contactAnyServer; $server->quit, return 0 unless $server->mail($from, %send_options); foreach (@to) { next if $server->to($_); # must we be able to disable this? # next if $args{ignore_erroneous_destinations} $server->quit; return 0; } $server->data; $server->datasend($_) foreach @header; my $bodydata = $message->body->file; if(ref $bodydata eq 'GLOB') { $server->datasend($_) while <$bodydata> } else { while(my $l = $bodydata->getline) { $server->datasend($l) } } $server->quit, return 0 unless $server->dataend; $server->quit; } #------------------------------------------ sub contactAnyServer() { my $self = shift; my ($enterval, $count, $timeout) = $self->retry; my ($host, $port, $username, $password) = $self->remoteHost; my @hosts = ref $host ? @$host : $host; foreach my $host (@hosts) { my $server = $self->tryConnectTo ( $host, Port => $port, , %{$self->{MTS_net_smtp_opts}}, Timeout => $timeout ); defined $server or next; $self->log(PROGRESS => "Opened SMTP connection to $host."); if(defined $username) { if($server->auth($username, $password)) { $self->log(PROGRESS => "$host: Authentication succeeded."); } else { $self->log(ERROR => "Authentication failed."); return undef; } } return $server; } undef; } sub tryConnectTo($@) { my ($self, $host) = (shift, shift); Net::SMTP->new($host, @_); } 1; Mail-Transport-3.002/lib/Mail/Transport/Mailx.pod0000644000175000001440000001611713232117764022326 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Mailx - transmit messages using external mailx program =head1 INHERITANCE Mail::Transport::Mailx is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $sender = Mail::Transport::Mailx->new(...); $sender->send($message); =head1 DESCRIPTION Implements mail transport using the external programs C<'mailx'>, C, or C<'mail'>. When instantiated, the mailer will look for any of these binaries in specific system directories, and the first program found is taken. B Under Linux, freebsd, and bsdos the C, C, and C names are just links to the same binary. The implementation is very primitive, pre-MIME standard, what may cause many headers to be lost. For these platforms (and probably for other platforms as well), you can better not use this transport mechanism. Extends L<"DESCRIPTION" in Mail::Transport::Send|Mail::Transport::Send/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Send|Mail::Transport::Send/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Send|Mail::Transport::Send/"Constructors">. =over 4 =item Mail::Transport::Mailx-EB(%options) -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport style timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' username Mail::Transport undef via Mail::Transport 'mailx' =over 2 =item executable => FILENAME =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item style => 'BSD'|'RFC822' There are two version of the C program. The newest accepts RFC822 messages, and automagically collect information about where the message is to be send to. The BSD style mail command predates MIME, and expects lines which start with a C<'~'> (tilde) to specify destinations and such. This field is autodetect, however on some platforms both versions of C can live (like various Linux distributions). =item timeout => SECONDS =item trace => LEVEL =item username => STRING =item via => CLASS|NAME =back =back =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Inherited, see L =item $obj-EB($message, $fh, %options) Inherited, see L =item $obj-EB($message, %options) Inherited, see L =item $obj-EB($message, %options) =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Send|Mail::Transport::Send/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Send|Mail::Transport::Send/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Mailx-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Mailx-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Mailx-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Send|Mail::Transport::Send/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =item Error: Sending via mailx mailer $program failed: $! ($?) Mailx (in some shape: there are many different implementations) did start accepting messages, but did not succeed sending it. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Sendmail.pod0000644000175000001440000001540013232117764023002 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Sendmail - transmit messages using external Sendmail program =head1 INHERITANCE Mail::Transport::Sendmail is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $sender = Mail::Transport::Sendmail->new(...); $sender->send($message); =head1 DESCRIPTION Implements mail transport using the external C<'Sendmail'> program. When instantiated, the mailer will look for the binary in specific system directories, and the first version found is taken. Some people use Postfix as MTA. Postfix can be installed as replacement for Sendmail: is provides a program with the same name and options. So, this module supports postfix as well. Extends L<"DESCRIPTION" in Mail::Transport::Send|Mail::Transport::Send/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Send|Mail::Transport::Send/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Send|Mail::Transport::Send/"Constructors">. =over 4 =item Mail::Transport::Sendmail-EB(%options) -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport sendmail_options [] timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' username Mail::Transport undef via Mail::Transport 'sendmail' =over 2 =item executable => FILENAME =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item sendmail_options => ARRAY Add to the command-line of the started sendmail MTU a list of separate words. So say C< [ '-f', $file ] > and not C< [ "-f $file" ] >, because the latter will be taken by sendmail as one word only. =item timeout => SECONDS =item trace => LEVEL =item username => STRING =item via => CLASS|NAME =back =back =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Inherited, see L =item $obj-EB($message, $fh, %options) Inherited, see L =item $obj-EB($message, %options) Inherited, see L =item $obj-EB($message, %options) -Option --Default sendmail_options undef =over 2 =item sendmail_options => ARRAY =back =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Send|Mail::Transport::Send/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Send|Mail::Transport::Send/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Sendmail-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Sendmail-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Sendmail-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Send|Mail::Transport::Send/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Error: Errors when closing sendmail mailer $program: $! The was no problem starting the sendmail mail transfer agent, but for some specific reason the message could not be handled correctly. =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Receive.pm0000644000175000001440000000114713232117763022464 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Receive; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport'; use strict; use warnings; sub receive(@) {shift->notImplemented} #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport/Send.pm0000644000175000001440000000536013232117763021774 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Send; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport'; use strict; use warnings; use Carp; use File::Spec; use Errno 'EAGAIN'; sub new(@) { my $class = shift; return $class->SUPER::new(@_) if $class ne __PACKAGE__; require Mail::Transport::Sendmail; Mail::Transport::Sendmail->new(@_); } #------------------------------------------ sub send($@) { my ($self, $message, %args) = @_; unless($message->isa('Mail::Message')) # avoid rebless. { $message = Mail::Message->coerce($message); confess "Unable to coerce object into Mail::Message." unless defined $message; } return 1 if $self->trySend($message, %args); return 0 unless $?==EAGAIN; my ($interval, $retry) = $self->retry; $interval = $args{interval} if exists $args{interval}; $retry = $args{retry} if exists $args{retry}; while($retry!=0) { sleep $interval; return 1 if $self->trySend($message, %args); return 0 unless $?==EAGAIN; $retry--; } 0; } #------------------------------------------ sub trySend($@) { my $self = shift; $self->log(ERROR => "Transporters of type ".ref($self). " cannot send."); } #------------------------------------------ sub putContent($$@) { my ($self, $message, $fh, %args) = @_; if($args{body_only}) { $message->body->print($fh) } elsif($args{undisclosed}) { $message->Mail::Message::print($fh) } else { $message->head->printUndisclosed($fh); $message->body->print($fh); } $self; } #------------------------------------------ sub destinations($;$) { my ($self, $message, $overrule) = @_; my @to; if(defined $overrule) # Destinations overruled by user. { my @addr = ref $overrule eq 'ARRAY' ? @$overrule : ($overrule); @to = map { ref $_ && $_->isa('Mail::Address') ? ($_) : Mail::Address->parse($_) } @addr; } elsif(my @rgs = $message->head->resentGroups) { @to = $rgs[0]->destinations; $self->log(WARNING => "Resent group does not specify a destination"), return () unless @to; } else { @to = $message->destinations; $self->log(WARNING => "Message has no destination"), return () unless @to; } @to; } #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport/Qmail.pm0000644000175000001440000000251313232117763022143 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Qmail; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport::Send'; use strict; use warnings; use Carp; sub init($) { my ($self, $args) = @_; $args->{via} = 'qmail'; $self->SUPER::init($args) or return; $self->{MTM_program} = $args->{proxy} || $self->findBinary('qmail-inject', '/var/qmail/bin') || return; $self; } #------------------------------------------ sub trySend($@) { my ($self, $message, %args) = @_; my $program = $self->{MTM_program}; if(open(MAILER, '|-')==0) { { exec $program; } $self->log(NOTICE => "Errors when opening pipe to $program: $!"); exit 1; } $self->putContent($message, \*MAILER, undisclosed => 1); unless(close MAILER) { $self->log(ERROR => "Errors when closing Qmail mailer $program: $!"); $? ||= $!; return 0; } 1; } #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport/Qmail.pod0000644000175000001440000001377613232117764022327 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Qmail - transmit messages using external Qmail program =head1 INHERITANCE Mail::Transport::Qmail is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $sender = Mail::Transport::Qmail->new(...); $sender->send($message); =head1 DESCRIPTION Implements mail transport using the external programs C<'qmail-inject'>, part of the qmail mail-delivery system. Extends L<"DESCRIPTION" in Mail::Transport::Send|Mail::Transport::Send/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Send|Mail::Transport::Send/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Send|Mail::Transport::Send/"Constructors">. =over 4 =item Mail::Transport::Qmail-EB(%options) -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport 'qmail-inject' retry Mail::Transport timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' username Mail::Transport undef via Mail::Transport 'qmail' =over 2 =item executable => FILENAME =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item timeout => SECONDS =item trace => LEVEL =item username => STRING =item via => CLASS|NAME =back =back =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Inherited, see L =item $obj-EB($message, $fh, %options) Inherited, see L =item $obj-EB($message, %options) Inherited, see L =item $obj-EB($message, %options) =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Send|Mail::Transport::Send/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Send|Mail::Transport::Send/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Qmail-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Qmail-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Qmail-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Send|Mail::Transport::Send/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Error: Errors when closing Qmail mailer $program: $! The Qmail mail transfer agent did start, but was not able to handle the message for some specific reason. =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Sendmail.pm0000644000175000001440000000313513232117763022635 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Sendmail; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport::Send'; use strict; use warnings; use Carp; sub init($) { my ($self, $args) = @_; $args->{via} = 'sendmail'; $self->SUPER::init($args) or return; $self->{MTS_program} = $args->{proxy} || $self->findBinary('sendmail') || return; $self->{MTS_opts} = $args->{sendmail_options} || []; $self; } #------------------------------------------ sub trySend($@) { my ($self, $message, %args) = @_; my $program = $self->{MTS_program}; if(open(MAILER, '|-')==0) { my $options = $args{sendmail_options} || []; my @to = map {$_->address} $self->destinations($message, $args{to}); # {} to avoid warning about code after exec { exec $program, '-i', @{$self->{MTS_opts}}, @$options, @to; } $self->log(NOTICE => "Errors when opening pipe to $program: $!"); exit 1; } $self->putContent($message, \*MAILER, undisclosed => 1); unless(close MAILER) { $self->log(NOTICE => "Errors when closing sendmail mailer $program: $!"); $? ||= $!; return 0; } 1; } #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport/SMTP.pod0000644000175000001440000002210713232117764022033 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::SMTP - transmit messages without external program =head1 INHERITANCE Mail::Transport::SMTP is a Mail::Transport::Send is a Mail::Transport is a Mail::Reporter =head1 SYNOPSIS my $sender = Mail::Transport::SMTP->new(...); $sender->send($message); $message->send(via => 'smtp'); =head1 DESCRIPTION This module implements transport of C objects by negotiating to the destination host directly by using the SMTP protocol, without help of C, C, or other programs on the local host. B you may need to install Net::SMTPS, to get TLS support. Extends L<"DESCRIPTION" in Mail::Transport::Send|Mail::Transport::Send/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport::Send|Mail::Transport::Send/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport::Send|Mail::Transport::Send/"Constructors">. =over 4 =item Mail::Transport::SMTP-EB(%options) -Option --Defined in --Default esmtp_options {} executable Mail::Transport undef from undef helo hostname Mail::Transport interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password undef port Mail::Transport 25 proxy Mail::Transport retry Mail::Transport smtp_debug timeout 120 trace Mail::Reporter 'WARNINGS' username undef via Mail::Transport 'smtp' =over 2 =item esmtp_options => HASH [2.116] ESMTP options to pass to Net::SMTP. See the L documentation for full details. Options can also be passed at send time. For example: C<< { XVERP => 1 } >> =item executable => FILENAME =item from => ADDRESS Allows a default sender address to be specified globally. See L for full details. =item helo => HOST The fully qualified name of the sender's host (your system) which is used for the greeting message to the receiver. If not specified, Net::Config or else Net::Domain are questioned to find it. When even these do not supply a valid name, the name of the domain in the C line of the message is assumed. =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING The password to be used with the new(username) to log in to the remote server. =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item smtp_debug => BOOLEAN Simulate transmission: the SMTP protocol output will be sent to your screen. =item timeout => SECONDS The number of seconds to wait for a valid response from the server before failing. =item trace => LEVEL =item username => STRING Use SASL authentication to contact the remote SMTP server (RFC2554). This username in combination with new(password) is passed as arguments to Net::SMTP method auth. Other forms of authentication are not supported by Net::SMTP. The C can also be specified as an Authen::SASL object. =item via => CLASS|NAME =back =back =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Inherited, see L =item $obj-EB($message, $fh, %options) Inherited, see L =item $obj-EB($message, %options) Inherited, see L =item $obj-EB($message, %options) Try to send the $message once. This may fail, in which case this method will return C. In list context, the reason for failure can be caught: in list context C will return a list of five values: (success, error code, error text, error location, quit success) Success and quit success are booleans. The error code and -text are protocol specific codes and texts. The location tells where the problem occurred. -Option --Default esmtp_options {} from < > to [] =over 2 =item esmtp_options => HASH Additional or overridden EMSTP options. See L =item from => ADDRESS Your own identification. This may be fake. If not specified, it is taken from L, which means the content of the C field of the message or the first address of the C field. This defaults to "E E", which represents "no address". =item to => ADDRESS|[ADDRESSES] Alternative destinations. If not specified, the C, C and C fields of the header are used. An address is a string or a Mail::Address object. =back =back =head2 Server connection Extends L<"Server connection" in Mail::Transport::Send|Mail::Transport::Send/"Server connection">. =over 4 =item $obj-EB() Creates the connection to the SMTP server. When more than one hostname was specified, the first which accepts a connection is taken. An IO::Socket::INET object is returned. =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB($host, %options) Try to establish a connection to deliver SMTP to the specified $host. The %options are passed to the C method of Net::SMTP. =back =head2 Error handling Extends L<"Error handling" in Mail::Transport::Send|Mail::Transport::Send/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::SMTP-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::SMTP-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::SMTP-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport::Send|Mail::Transport::Send/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Notice: No addresses found to send the message to, no connection made =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Receive.pod0000644000175000001440000001115713232117764022635 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Receive - receive messages =head1 INHERITANCE Mail::Transport::Receive is a Mail::Transport is a Mail::Reporter Mail::Transport::Receive is extended by Mail::Transport::IMAP4 Mail::Transport::POP3 =head1 SYNOPSIS my $receiver = Mail::Transport::POP3->new(...); my $message = $receiver->receive($id); =head1 DESCRIPTION Each object which extends L implement a protocol which can get messages into your application. The internals of each implementation can differ quite a lot, so have a look at each separate manual page as well. Current message receivers: =over 4 =item * L Implements the POP3 protocol. See also L. =back Extends L<"DESCRIPTION" in Mail::Transport|Mail::Transport/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport|Mail::Transport/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport|Mail::Transport/"Constructors">. =over 4 =item Mail::Transport::Receive-EB(%options) Inherited, see L =back =head2 Receiving mail =over 4 =item $obj-EB( [$unique_message_id] ) Receive one message from the remote server. Some receivers will provide the next message automatically, other are random access and use the specified ID. =back =head2 Server connection Extends L<"Server connection" in Mail::Transport|Mail::Transport/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport|Mail::Transport/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Receive-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Receive-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Receive-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport|Mail::Transport/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Warning: Avoid program abuse: specify an absolute path for $exec. Specifying explicit locations for executables of email transfer agents should only be done with absolute file names, to avoid various pontential security problems. =item Warning: Executable $exec does not exist. The explicitly indicated mail transfer agent does not exists. The normal settings are used to find the correct location. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Send.pod0000644000175000001440000002160313232117764022141 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport::Send - send a message =head1 INHERITANCE Mail::Transport::Send is a Mail::Transport is a Mail::Reporter Mail::Transport::Send is extended by Mail::Transport::Exim Mail::Transport::Mailx Mail::Transport::Qmail Mail::Transport::SMTP Mail::Transport::Sendmail =head1 SYNOPSIS my $message = Mail::Message->new(...); # Some extensions implement sending: $message->send; $message->send(via => 'sendmail'); my $sender = Mail::Transport::SMTP->new(...); $sender->send($message); =head1 DESCRIPTION Send a message to the destinations as specified in the header. The C module is capable of autodetecting which of the following modules work on your system; you may simply call C without C options to get a message transported. =over 4 =item * L Use sendmail to process and deliver the mail. This requires the C program to be installed on your system. Whether this is an original sendmail, or a replacement from Postfix does matter. =item * L Use C to distribute the message. =item * L Use C to distribute the message. =item * L In this case, Perl is handling mail transport on its own. This is less desired but more portable than sending with sendmail or qmail. The advantage is that this sender is environment independent, and easier to configure. However, there is no daemon involved which means that your program will wait until the message is delivered, and the message is lost when your program is interrupted during delivery (which may take hours to complete). =item * L Use the external C, C, or C programs to send the message. Usually, the result is poor, because some versions of these programs do not support MIME headers. Besides, these programs are known to have exploitable security breaches. =back Extends L<"DESCRIPTION" in Mail::Transport|Mail::Transport/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Transport|Mail::Transport/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Transport|Mail::Transport/"Constructors">. =over 4 =item Mail::Transport::Send-EB(%options) -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 log Mail::Reporter 'WARNINGS' password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport timeout Mail::Transport 120 trace Mail::Reporter 'WARNINGS' username Mail::Transport undef via Mail::Transport 'sendmail' =over 2 =item executable => FILENAME =item hostname => HOSTNAME|ARRAY =item interval => SECONDS =item log => LEVEL =item password => STRING =item port => INTEGER =item proxy => PATH =item retry => NUMBER|undef =item timeout => SECONDS =item trace => LEVEL =item username => STRING =item via => CLASS|NAME =back =back =head2 Sending mail =over 4 =item $obj-EB( $message, [$address|ARRAY] ) Determine the destination for this message. If a valid $address is defined, this is used to overrule the addresses within the message. If the $address is C it is ignored. It may also be an ARRAY of addresses. If no $address is specified, the message is scanned for resent groups (see L). The addresses found in the first (is latest added) group are used. If no resent groups are found, the normal C, C, and C lines are taken. =item $obj-EB($message, $fh, %options) Print the content of the $message to the $fh. -Option --Default body_only undisclosed =over 2 =item body_only => BOOLEAN Print only the body of the message, not the whole. =item undisclosed => BOOLEAN Do not print the C and C lines. Default false, which means that they are not printed. =back =item $obj-EB($message, %options) Transmit the $message, which may be anything what can be coerced into a L, so including Mail::Internet and MIME::Entity messages. It returns true when the transmission was successfully completed. -Option --Default interval new(interval) retry new(retry) to undef =over 2 =item interval => SECONDS =item retry => INTEGER =item to => STRING Overrules the destination(s) of the message, which is by default taken from the (Resent-)To, (Resent-)Cc, and (Resent-)Bcc. =back =item $obj-EB($message, %options) Try to send the message. This will return true if successful, and false in case some problems where detected. The C<$?> contains the exit status of the command which was started. =back =head2 Server connection Extends L<"Server connection" in Mail::Transport|Mail::Transport/"Server connection">. =over 4 =item $obj-EB( $name, [@directories] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Error handling Extends L<"Error handling" in Mail::Transport|Mail::Transport/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport::Send-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport::Send-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport::Send-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Transport|Mail::Transport/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Warning: Message has no destination It was not possible to figure-out where the message is intended to go to. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =item Warning: Resent group does not specify a destination The message which is sent is the result of a bounce (for instance created with L), and therefore starts with a C header field. With the C, the new destination(s) of the message are given, which should be included as C, C, and C. The C, C, and C header information is only used if no C was found. That seems to be the best explanation of the RFC. As alternative, you may also specify the C option to some of the senders (for instance L to overrule any information found in the message itself about the destination. =item Error: Transporters of type $class cannot send. The L object of the specified type can not send messages, but only receive message. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport/Mailx.pm0000644000175000001440000000502413232117763022152 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Mailx; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport::Send'; use strict; use warnings; use Carp; sub init($) { my ($self, $args) = @_; $args->{via} = 'mailx'; $self->SUPER::init($args) or return; $self->{MTM_program} = $args->{proxy} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail') || return; $self->{MTM_style} = defined $args->{style} ? $args->{style} : $^O =~ m/linux|freebsd|bsdos|netbsd|openbsd/ ? 'BSD' : 'RFC822'; $self; } #------------------------------------------ sub _try_send_bsdish($$) { my ($self, $message, $args) = @_; my @options = ('-s' => $message->subject); { local $" = ','; my @cc = map {$_->format} $message->cc; push @options, ('-c' => "@cc") if @cc; my @bcc = map {$_->format} $message->bcc; push @options, ('-b' => "@bcc") if @bcc; } my @to = map {$_->format} $message->to; my $program = $self->{MTM_program}; if((open MAILER, '|-')==0) { close STDOUT; { exec $program, @options, @to } $self->log(NOTICE => "Cannot start contact to $program: $!"); exit 1; } $self->putContent($message, \*MAILER, body_only => 1); my $msgid = $message->messageId; if(close MAILER) { $self->log(PROGRESS => "Message $msgid send.") } else { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)"); return 0; } 1; } sub trySend($@) { my ($self, $message, %args) = @_; return $self->_try_send_bsdish($message, \%args) if $self->{MTM_style} eq 'BSD'; my $program = $self->{MTM_program}; unless(open MAILER, '|-', $program, '-t') { $self->log(NOTICE => "Cannot start contact to $program: $!"); return 0; } $self->putContent($message, \*MAILER); unless(close MAILER) { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)"); return 0; } 1; } #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport/Exim.pm0000644000175000001440000000316013232117763022001 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport::Exim; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Transport::Send'; use strict; use warnings; use Carp; sub init($) { my ($self, $args) = @_; $args->{via} = 'exim'; $self->SUPER::init($args) or return; $self->{MTS_program} = $args->{proxy} || ( -x '/usr/sbin/exim4' ? '/usr/sbin/exim4' : undef) || $self->findBinary('exim', '/usr/exim/bin') || return; $self; } #------------------------------------------ sub trySend($@) { my ($self, $message, %args) = @_; my $from = $args{from} || $message->sender; $from = $from->address if ref $from && $from->isa('Mail::Address'); my @to = map {$_->address} $self->destinations($message, $args{to}); my $program = $self->{MTS_program}; if(open(MAILER, '|-')==0) { { exec $program, '-i', '-f', $from, @to; } # {} to avoid warning $self->log(NOTICE => "Errors when opening pipe to $program: $!"); exit 1; } $self->putContent($message, \*MAILER, undisclosed => 1); unless(close MAILER) { $self->log(ERROR => "Errors when closing Exim mailer $program: $!"); $? ||= $!; return 0; } 1; } #------------------------------------------ 1; Mail-Transport-3.002/lib/Mail/Transport.pod0000644000175000001440000001613213232117764021251 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Mail::Transport - use Mail Transfer Agents (MTAs) =head1 INHERITANCE Mail::Transport is a Mail::Reporter Mail::Transport is extended by Mail::Transport::Receive Mail::Transport::Send =head1 SYNOPSIS my $message = Mail::Message->new(...); # Some extensions implement sending: $message->send; $message->send(via => 'sendmail'); my $sender = Mail::Transport::SMTP->new(...); $sender->send($message); # Some extensions implement receiving: my $receiver = Mail::Transport::POP3->new(...); $message = $receiver->receive; =head1 DESCRIPTION Objects which extend C implement sending and/or receiving of messages, using various protocols. L extends this class, and offers general functionality for send protocols, like SMTP. L also extends this class, and offers receive method. Some transport protocols will implement both sending and receiving. Extends L<"DESCRIPTION" in Mail::Reporter|Mail::Reporter/"DESCRIPTION">. =head1 METHODS Extends L<"METHODS" in Mail::Reporter|Mail::Reporter/"METHODS">. =head2 Constructors Extends L<"Constructors" in Mail::Reporter|Mail::Reporter/"Constructors">. =over 4 =item Mail::Transport-EB(%options) -Option --Defined in --Default executable undef hostname 'localhost' interval 30 log Mail::Reporter 'WARNINGS' password undef port undef proxy undef retry timeout 120 trace Mail::Reporter 'WARNINGS' username undef via 'sendmail' =over 2 =item executable => FILENAME If you specify an executable, the module does not need to search the system directories to figure-out where the client lives. Using this decreases the flexible usage of your program: moving your program to other systems may involve changing the path to the executable, which otherwise would work auto-detect and unmodified. =item hostname => HOSTNAME|ARRAY The host on which the server runs. Some protocols accept an ARRAY of alternatives for this option. =item interval => SECONDS The time between tries to contact the remote server for sending or receiving a message in SECONDS. This number must be larger than 0. =item log => LEVEL =item password => STRING Some protocols require a password to be given, usually in combination with a password. =item port => INTEGER The port number behind which the service is hiding on the remote server. =item proxy => PATH The name of the proxy software (the protocol handler). This must be the name (preferable the absolute path) of your mail delivery software. =item retry => NUMBER|undef The number of retries before the sending will fail. If C, the number of retries is unlimited. =item timeout => SECONDS SECONDS till time-out while establishing the connection to a remote server. =item trace => LEVEL =item username => STRING Some protocols require a user to login. =item via => CLASS|NAME Which CLASS (extending C) will transport the data. Some predefined NAMEs avoid long class names: C and C are handled by the L module, C and C belong to L, and C is implemented in L. The C or C protocol implementation can be found in L. =back =back =head2 Server connection =over 4 =item $obj-EB( $name, [@directories] ) Look for a binary with the specified $name in the directories which are defined to be safe. The list of standard directories is followed by the optional @directories. The full pathname is returned. You may specify L, which specifies the absolute name of the binary to be used. =item $obj-EB() Returns the hostname, port number, username and password to be used to establish the connection to the server for sending or receiving mail. =item $obj-EB() Returns the retry interval, retry count, and timeout for the connection. =back =head2 Error handling Extends L<"Error handling" in Mail::Reporter|Mail::Reporter/"Error handling">. =over 4 =item $obj-EB() Inherited, see L =item $obj-EB($object) Inherited, see L =item $obj-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) =item Mail::Transport-EB( [$level]|[$loglevel, $tracelevel]|[$level, $callback] ) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level, [$strings]] ) =item Mail::Transport-EB( [$level, [$strings]] ) Inherited, see L =item $obj-EB($level) =item Mail::Transport-EB($level) Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB() Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB( [$level] ) Inherited, see L =item $obj-EB() Inherited, see L =back =head2 Cleanup Extends L<"Cleanup" in Mail::Reporter|Mail::Reporter/"Cleanup">. =over 4 =item $obj-EB() Inherited, see L =back =head1 DIAGNOSTICS =over 4 =item Warning: Avoid program abuse: specify an absolute path for $exec. Specifying explicit locations for executables of email transfer agents should only be done with absolute file names, to avoid various pontential security problems. =item Warning: Executable $exec does not exist. The explicitly indicated mail transfer agent does not exists. The normal settings are used to find the correct location. =item Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. =back =head1 SEE ALSO This module is part of Mail-Transport distribution version 3.002, built on January 24, 2018. Website: F =head1 LICENSE Copyrights 2001-2018 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Mail-Transport-3.002/lib/Mail/Transport.pm0000644000175000001440000000540313232117763021101 0ustar00markovusers00000000000000# Copyrights 2001-2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Mail-Transport. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Mail::Transport; use vars '$VERSION'; $VERSION = '3.002'; use base 'Mail::Reporter'; use strict; use warnings; use Carp; use File::Spec; my %mailers = ( exim => '::Exim' , mail => '::Mailx' , mailx => '::Mailx' , pop => '::POP3' , pop3 => '::POP3' , postfix => '::Sendmail' , qmail => '::Qmail' , sendmail => '::Sendmail' , smtp => '::SMTP' ); sub new(@) { my $class = shift; return $class->SUPER::new(@_) unless $class eq __PACKAGE__ || $class eq "Mail::Transport::Send"; # # auto restart by creating the right transporter. # my %args = @_; my $via = lc($args{via} || '') or croak "No transport protocol provided"; $via = 'Mail::Transport'.$mailers{$via} if exists $mailers{$via}; eval "require $via"; return undef if $@; $via->new(@_); } sub init($) { my ($self, $args) = @_; $self->SUPER::init($args); $self->{MT_hostname} = defined $args->{hostname} ? $args->{hostname} : 'localhost'; $self->{MT_port} = $args->{port}; $self->{MT_username} = $args->{username}; $self->{MT_password} = $args->{password}; $self->{MT_interval} = $args->{interval} || 30; $self->{MT_retry} = $args->{retry} || -1; $self->{MT_timeout} = $args->{timeout} || 120; $self->{MT_proxy} = $args->{proxy}; if(my $exec = $args->{executable} || $args->{proxy}) { $self->{MT_exec} = $exec; $self->log(WARNING => "Avoid program abuse: specify an absolute path for $exec.") unless File::Spec->file_name_is_absolute($exec); unless(-x $exec) { $self->log(WARNING => "Executable $exec does not exist."); return undef; } } $self; } #------------------------------------------ sub remoteHost() { my $self = shift; @$self{ qw/MT_hostname MT_port MT_username MT_password/ }; } sub retry() { my $self = shift; @$self{ qw/MT_interval MT_retry MT_timeout/ }; } my @safe_directories = qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib); sub findBinary($@) { my ($self, $name) = (shift, shift); return $self->{MT_exec} if exists $self->{MT_exec}; foreach (@_, @safe_directories) { my $fullname = File::Spec->catfile($_, $name); return $fullname if -x $fullname; } undef; } #------------------------------------------ 1; Mail-Transport-3.002/MANIFEST0000644000175000001440000000124313232117764016247 0ustar00markovusers00000000000000ChangeLog MANIFEST Makefile.PL README README.md lib/Mail/Transport.pm lib/Mail/Transport.pod lib/Mail/Transport/Exim.pm lib/Mail/Transport/Exim.pod lib/Mail/Transport/Mailx.pm lib/Mail/Transport/Mailx.pod lib/Mail/Transport/Qmail.pm lib/Mail/Transport/Qmail.pod lib/Mail/Transport/Receive.pm lib/Mail/Transport/Receive.pod lib/Mail/Transport/SMTP.pm lib/Mail/Transport/SMTP.pod lib/Mail/Transport/Send.pm lib/Mail/Transport/Send.pod lib/Mail/Transport/Sendmail.pm lib/Mail/Transport/Sendmail.pod t/001use.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Mail-Transport-3.002/README.md0000644000175000001440000000437513232117627016404 0ustar00markovusers00000000000000# distribution Mail-Transport * My extended documentation: * Development via GitHub: * Download from CPAN: * Indexed from CPAN: and Until release 3.0, this module was an integral part of the Mail-Box distribution. This distribution is dedicate to sending email messages via various Mail Transfer Agents (MTAs) like postfix or exim. It is part of the MailBox collection of modules, however: you are not limited to "Mail::Message" messages. ## Development → Release Important to know, is that I use an extension on POD to write the manuals. The "raw" unprocessed version is visible on GitHub. It will run without problems, but does not contain manual-pages. Releases to CPAN are different: "raw" documentation gets removed from the code and translated into real POD and clean HTML. This reformatting is implemented with the OODoc distribution (A name I chose before OpenOffice existed, sorry for the confusion) Clone from github for the "raw" version. For instance, when you want to contribute a new feature. On github, you can find the processed version for each release. But the better source is CPAN; to get it installed simply run: ```sh cpan -i Mail::Transport ``` ## Contributing When you want to contribute to this module, you do not need to provide a perfect patch... actually: it is nearly impossible to create a patch which I will merge without modification. Usually, I need to adapt the style of code and documentation to my own strict rules. When you submit an extension, please contribute a set with 1. code 2. code documentation 3. regression tests in t/ **Please note:** When you contribute in any way, you agree to transfer the copyrights to Mark Overmeer (you will get the honors in the code and/or ChangeLog). You also automatically agree that your contribution is released under the same license as this project: licensed as perl itself. ## Copyright and License This project is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See Mail-Transport-3.002/ChangeLog0000644000175000001440000000075613232117763016677 0ustar00markovusers00000000000000 ===== Revision history of Mail::Transport version 3.* All changes are made by Mark Overmeer unless explicitly stated differently. version 3.002: Wed 24 Jan 16:02:02 CET 2018 Improvements: - convert to GIT - publish on GitHUB version 3.001: Wed 8 Nov 13:06:18 CET 2017 Fixes: - link to Perl licenses. rt.cpan.org#120319 [Jitka Plesnikova] version 3.000: Thu 2 Feb 15:41:59 CET 2017 Changes: - split-off from Mail::Box - supports perl from 5.10 (was 5.8.5) Mail-Transport-3.002/t/0000755000175000001440000000000013232117764015361 5ustar00markovusers00000000000000Mail-Transport-3.002/t/001use.t0000644000175000001440000000163313200571500016551 0ustar00markovusers00000000000000#!/usr/bin/env perl use warnings; use strict; use Test::More tests => 8; # The versions of the following packages are reported to help understanding # the environment in which the tests are run. This is certainly not a # full list of all installed modules. my @show_versions = qw/Mail::Box Mail::Box::Manager Mail::Message /; foreach my $package (@show_versions) { eval "require $package"; no strict 'refs'; my $report = !$@ ? "version ". (${"$package\::VERSION"} || 'unknown') : $@ =~ m/^Can't locate/ ? "not installed" : "reports error"; warn "$package $report\n"; } require_ok('Mail::Transport'); require_ok('Mail::Transport::Exim'); require_ok('Mail::Transport::Mailx'); require_ok('Mail::Transport::Qmail'); require_ok('Mail::Transport::Receive'); require_ok('Mail::Transport::Sendmail'); require_ok('Mail::Transport::Send'); require_ok('Mail::Transport::SMTP'); Mail-Transport-3.002/README0000644000175000001440000000146113200571501015764 0ustar00markovusers00000000000000=== README for Mail-Transport version 3.001 = Generated on Wed Nov 8 13:06:25 2017 by OODoc 2.02 There are various ways to install this module: (1) if you have a command-line, you can do: perl -MCPAN -e 'install ' (2) if you use Windows, have a look at http://ppm.activestate.com/ (3) if you have downloaded this module manually (as root/administrator) gzip -d Mail-Transport-3.001.tar.gz tar -xf Mail-Transport-3.001.tar cd Mail-Transport-3.001 perl Makefile.PL make # optional make test # optional make install For usage, see the included manual-pages or http://search.cpan.org/dist/Mail-Transport-3.001/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=Mail-Transport Mail-Transport-3.002/Makefile.PL0000644000175000001440000000402013232117712017055 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; require 5.010; use IO::Handle; my $VERSION = '3.002'; my %prereq = ( Carp => 0 , List::Util => 0 , IO::Socket => 0 , File::Spec => 0.7 , Errno => 0 , Net::SMTP => 0 , Mail::Reporter => 3 ); foreach my $module (sort keys %prereq) { my $reqversion = $prereq{$module}; eval "require $module"; if($@ && $@ =~ m/^Can't locate /) { print " $module is not yet installed\n" } elsif($@) { print " $module produced an error:\n$@"; push @errors, $module; } elsif($module->VERSION < $reqversion) { print " $module version ",$module->VERSION , " is outdated; requires $reqversion\n"; } else { print " $module version ",$module->VERSION , " is ok (required is $reqversion)\n"; } } if($errors) { die <<'FIX'; *** ERROR! You have to install @errors manually, *** before you can retry to install MailBox. FIX exit 1; } WriteMakefile ( NAME => 'Mail::Transport' , VERSION => $VERSION , AUTHOR => 'Mark Overmeer' , ABSTRACT => 'Email message exchange' , PREREQ_PM => \%prereq , LICENSE => 'perl' , META_MERGE => { 'meta-spec' => { version => 2 } , resources => { repository => { type => 'git' , url => 'https://github.com/markov2/perl5-Mail-Transport.git' , web => 'https://github.com/markov2/perl5-Mail-Transport' } } , homepage => 'http://perl.overmeer.net/CPAN/' , license => [ 'http://dev.perl.org/licenses/' ] } ); ### used by oodist during production of distribution sub MY::postamble { <<'__POSTAMBLE' } # for DIST RAWDIR = ../public_html/mail-transport/raw DISTDIR = ../public_html/mail-transport/source LICENSE = perl EXTENDS = ../../perl/MailMessage:../../perl/MailPOP:../../perl/MailIMAP # for POD FIRST_YEAR = 2001 EMAIL = markov@cpan.org WEBSITE = http://perl.overmeer.net/CPAN/ __POSTAMBLE Mail-Transport-3.002/META.yml0000644000175000001440000000136613232117764016375 0ustar00markovusers00000000000000--- abstract: 'Email message exchange' author: - 'Mark Overmeer' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Mail-Transport no_index: directory: - t - inc requires: Carp: '0' Errno: '0' File::Spec: '0.7' IO::Socket: '0' List::Util: '0' Mail::Reporter: '3' Net::SMTP: '0' resources: repository: https://github.com/markov2/perl5-Mail-Transport.git version: '3.002' x_homepage: http://perl.overmeer.net/CPAN/ x_serialization_backend: 'CPAN::Meta::YAML version 0.011' Mail-Transport-3.002/META.json0000644000175000001440000000254613232117764016546 0ustar00markovusers00000000000000{ "abstract" : "Email message exchange", "author" : [ "Mark Overmeer" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5", "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Mail-Transport", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Errno" : "0", "File::Spec" : "0.7", "IO::Socket" : "0", "List::Util" : "0", "Mail::Reporter" : "3", "Net::SMTP" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/markov2/perl5-Mail-Transport.git", "web" : "https://github.com/markov2/perl5-Mail-Transport" } }, "version" : "3.002", "x_homepage" : "http://perl.overmeer.net/CPAN/", "x_serialization_backend" : "JSON::PP version 2.94" }