Mail-Transport-4.01/0000755000175000001440000000000015117245665015044 5ustar00markovusers00000000000000Mail-Transport-4.01/lib/0000755000175000001440000000000015117245665015612 5ustar00markovusers00000000000000Mail-Transport-4.01/lib/Mail/0000755000175000001440000000000015117245665016474 5ustar00markovusers00000000000000Mail-Transport-4.01/lib/Mail/Transport/0000755000175000001440000000000015117245665020470 5ustar00markovusers00000000000000Mail-Transport-4.01/lib/Mail/Transport/Send.pod0000644000175000001440000002000215117245664022056 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 $class-EB(%options) Inherited, see L -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport timeout Mail::Transport 120 username Mail::Transport undef via Mail::Transport 'sendmail' =over 2 =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item password => $password =item port => $port =item proxy => $path =item retry => $count|undef =item timeout => $span =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport|Mail::Transport/"Attributes">. =head2 Sending mail =over 4 =item $obj-EB( $message, [$address|\@addresses] ) Determine the destination for this message. If a valid C<$address> is defined, this is used to overrule the addresses within the message. If the C<$address> is C it is ignored. It may also be an ARRAY of C<@addresses>. If no C<$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 C<$message> to the C<$fh>. The content might not end with new-line. See L -Option --Default body_only false undisclosed false =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 C, which means that they are not printed. =back =item $obj-EB($message, %options) Transmit the C<$message>, which may be anything what can be coerced into a L, so including L and MIME::Entity messages. It returns C 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 C if successful, and C 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() 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 Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =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. Cast by C =item Error: transporters of type $class cannot send. The L object of the specified type can not send messages, but only receive message. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/Sendmail.pm0000644000175000001440000000311715117245663022562 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Sendmail;{ our $VERSION = '4.01'; } use parent 'Mail::Transport::Send'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error fault warning/ ]; #-------------------- sub init($) { my ($self, $args) = @_; $args->{via} = 'sendmail'; $self->SUPER::init($args); $self->{MTS_program} = $args->{proxy} || $self->findBinary('sendmail') or return; $self->{MTS_opts} = $args->{sendmail_options} || []; $self; } #-------------------- sub trySend($@) { my ($self, $message, %args) = @_; my $program = $self->{MTS_program}; my $mailer; if(open($mailer, '|-')==0) { # Child process is sendmail binary 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; } fault __x"cannot open pipe to {program}", program => $program; } # Parent process is the main program, still $self->putContent($message, $mailer, undisclosed => 1); $mailer->close or fault __x"errors when closing sendmail mailer {program}", program => $program; 1; } 1; Mail-Transport-4.01/lib/Mail/Transport/Sendmail.pod0000644000175000001440000001433715117245664022737 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. B When you do bulk email sending with local delivery via Postfix, you can probably better use the SMTP backend to connect to postfix. The C command delivers to C. From C, the C will only sequentially insert messages into C. That process can take considerable elapse time. Directly inserting via C will parallellize the cleanup process. 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 $class-EB(%options) Inherited, see L -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport sendmail_options [] timeout Mail::Transport 120 username Mail::Transport undef via Mail::Transport 'sendmail' =over 2 =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item password => $password =item port => $port =item proxy => $path =item retry => $count|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 => $span =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport::Send|Mail::Transport::Send/"Attributes">. =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|\@addresses] ) 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) Inherited, see L -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() 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. Cast by C =item Fault: cannot open pipe to $program: $! Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/Exim.pm0000644000175000001440000000311715117245663021730 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Exim;{ our $VERSION = '4.01'; } use parent 'Mail::Transport::Send'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error fault warning/ ]; use Scalar::Util qw/blessed/; #-------------------- sub init($) { my ($self, $args) = @_; $args->{via} = 'exim'; $self->SUPER::init($args); $self->{MTS_program} = $args->{proxy} || ( -x '/usr/sbin/exim4' ? '/usr/sbin/exim4' : undef) || $self->findBinary('exim', '/usr/exim/bin') or error __x"cannot find binary for exim."; $self; } sub trySend($@) { my ($self, $message, %args) = @_; my $from = $args{from} || $message->sender; $from = $from->address if blessed $from && $from->isa('Mail::Address'); my @to = map $_->address, $self->destinations($message, $args{to}); my $program = $self->{MTS_program}; my $mailer; if(open($mailer, '|-')==0) { { exec $program, '-i', '-f', $from, @to; } # {} to avoid warning fault __x"cannot open pipe to {program}", program => $program; } $self->putContent($message, $mailer, undisclosed => 1); $mailer->close or fault __x"errors when closing Exim mailer {program}", program => $program; 1; } 1; Mail-Transport-4.01/lib/Mail/Transport/Qmail.pod0000644000175000001440000001226215117245664022241 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 $class-EB(%options) Inherited, see L -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport 'qmail-inject' retry Mail::Transport timeout Mail::Transport 120 username Mail::Transport undef via Mail::Transport 'qmail' =over 2 =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item password => $password =item port => $port =item proxy => $path =item retry => $count|undef =item timeout => $span =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport::Send|Mail::Transport::Send/"Attributes">. =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|\@addresses] ) 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) Inherited, see L =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() 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. Cast by C =item Fault: cannot open pipe to $program: $! Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Fault: errors when closing Qmail mailer $program: $! Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/SMTP.pod0000644000175000001440000002123315117245664021757 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 $class-EB(%options) Inherited, see L -Option --Defined in --Default esmtp_options {} executable Mail::Transport undef from undef helo hostname Mail::Transport interval Mail::Transport 30 password undef port Mail::Transport 25 proxy Mail::Transport retry Mail::Transport smtp_debug false timeout 120 username undef via Mail::Transport 'smtp' =over 2 =item esmtp_options => \%opts [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 => $file =item from => $address Allows a default sender C<$address> to be specified globally. See L for full details. =item helo => $host The fully qualified name of the sender's C<$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 => $host|\@hosts =item interval => $span =item password => $password The password to be used with the C to log in to the remote server. =item port => $port =item proxy => $path =item retry => $count|undef =item smtp_debug => BOOLEAN Simulate transmission: the SMTP protocol output will be sent to your screen. =item timeout => $wait The number of seconds to C<$wait> for a valid response from the server before failing. =item username => $username Use SASL authentication to contact the remote SMTP server (RFC2554). This C<$username> in combination with C 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 Attributes Extends L<"Attributes" in Mail::Transport::Send|Mail::Transport::Send/"Attributes">. =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|\@addresses] ) 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 C<$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 six values: (success, rc, rc-text, error location, quit success, accept) Success and quit success are booleans. The error code and -text are protocol specific codes and texts. The location tells where the problem occurred. [3.003] the 'accept' returns the message of the L instruction. Some servers may provide useful information in there, like an internal message registration id. For example, postfix may return "2.0.0 Ok: queued as 303EA380EE". You can only use this parameter when running local delivery (which is a smart choice anyway) Improves base, see L -Option --Default esmtp_options +{} from < > to [] =over 2 =item esmtp_options => \%opts 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 C<$address> is a string or a L 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 C<$host>. The C<%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() 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: authentication for $host failed. Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =item Notice: no addresses found to send the message to, no connection made. Cast by C =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. Cast by C =item Warning: use option `to' to overrule the destination: `To' refers to a field. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/Exim.pod0000644000175000001440000001265015117245664022101 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 $class-EB(%options) If you have Exim installed in a non-standard location, you will need to specify the path, using L. Improves base, see L -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport timeout Mail::Transport 120 username Mail::Transport undef via Mail::Transport 'exim' =over 2 =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item password => $password =item port => $port =item proxy => $path =item retry => $count|undef =item timeout => $span =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport::Send|Mail::Transport::Send/"Attributes">. =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|\@addresses] ) 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) Inherited, see L =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() 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. Cast by C =item Error: cannot find binary for exim. Cast by C =item Fault: cannot open pipe to $program: $! Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Fault: errors when closing Exim mailer $program: $! Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/Receive.pm0000644000175000001440000000127615117245663022414 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Receive;{ our $VERSION = '4.01'; } use parent 'Mail::Transport'; use strict; use warnings; use Log::Report 'mail-transport', import => [ ]; #-------------------- sub receive(@) { $_[0]->notImplemented } #-------------------- 1; Mail-Transport-4.01/lib/Mail/Transport/Mailx.pod0000644000175000001440000001435115117245664022251 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 $class-EB(%options) Inherited, see L -Option --Defined in --Default executable Mail::Transport undef hostname Mail::Transport 'localhost' interval Mail::Transport 30 password Mail::Transport undef port Mail::Transport undef proxy Mail::Transport undef retry Mail::Transport style timeout Mail::Transport 120 username Mail::Transport undef via Mail::Transport 'mailx' =over 2 =item executable => $file =item hostname => $host|\@hosts =item interval => $span =item password => $password =item port => $port =item proxy => $path =item retry => $count|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 => $span =item username => $username =item via => CLASS|$name =back =back =head2 Attributes Extends L<"Attributes" in Mail::Transport::Send|Mail::Transport::Send/"Attributes">. =head2 Sending mail Extends L<"Sending mail" in Mail::Transport::Send|Mail::Transport::Send/"Sending mail">. =over 4 =item $obj-EB( $message, [$address|\@addresses] ) 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) Inherited, see L =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() 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: cannot find binary of mailx. Cast by C =item Fault: cannot open pipe to $program: $! Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =item Warning: message has no destination. It was not possible to figure-out where the message is intended to go to. Cast by C =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. Cast by C =item Fault: 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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport/Qmail.pm0000644000175000001440000000235515117245663022074 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Qmail;{ our $VERSION = '4.01'; } use parent 'Mail::Transport::Send'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error fault/ ]; #-------------------- sub init($) { my ($self, $args) = @_; $args->{via} = 'qmail'; $self->SUPER::init($args); $self->{MTM_program} = $args->{proxy} || $self->findBinary('qmail-inject', '/var/qmail/bin') or return; $self; } sub trySend($@) { my ($self, $message, %args) = @_; my $program = $self->{MTM_program}; my $mailer; if(open($mailer, '|-')==0) { { exec $program; } fault __x"cannot open pipe to {program}.", program => $program; } $self->putContent($message, $mailer, undisclosed => 1); $mailer->close or fault __x"errors when closing Qmail mailer {program}", program => $program; 1; } 1; Mail-Transport-4.01/lib/Mail/Transport/Mailx.pm0000644000175000001440000000422215117245663022076 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Mailx;{ our $VERSION = '4.01'; } use parent 'Mail::Transport::Send'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x fault error/ ]; #-------------------- 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') or error __x"cannot find binary of mailx."; $self->{MTM_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}; my $mailer; if((open $mailer, '|-')==0) { close STDOUT; { exec $program, @options, @to } fault __x"cannot open pipe to {program}", program => $program; } $self->putContent($message, $mailer, body_only => 1); $mailer->close or fault __x"errors when closing Mailx mailer {program}", program => $program; 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}; open my $mailer, '|-', $program, '-t' or fault __x"cannot open pipe to {program}", program => $program; $self->putContent($message, $mailer); $mailer->close or fault __x"errors when closing Mailx mailer {program}", program => $program; 1; } 1; Mail-Transport-4.01/lib/Mail/Transport/Send.pm0000644000175000001440000000453115117245663021720 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::Send;{ our $VERSION = '4.01'; } use parent 'Mail::Transport'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error warning/ ]; use File::Spec (); use Errno 'EAGAIN'; #-------------------- sub new(@) { my $class = shift; $class eq __PACKAGE__ or return $class->SUPER::new(@_); require Mail::Transport::Sendmail; Mail::Transport::Sendmail->new(@_); } #-------------------- sub send($@) { my ($self, $message, %args) = @_; $message = Mail::Message->coerce($message) unless $message->isa('Mail::Message'); $self->trySend($message, %args) and return 1; $?==EAGAIN or return 0; 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); $?==EAGAIN or return 0; $retry--; } 0; } sub trySend($@) { my $self = shift; error __x"transporters of type {class} cannot send.", class => ref $self; } 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. { @to = map { ref $_ && $_->isa('Mail::Address') ? ($_) : Mail::Address->parse($_) } ref $overrule eq 'ARRAY' ? @$overrule : ($overrule); } elsif(my @rgs = $message->head->resentGroups) { # Create with bounce @to = $rgs[0]->destinations; @to or warning(__x"resent group does not specify a destination."), return (); } else { @to = $message->destinations; @to or warning(__x"message has no destination."), return (); } @to; } #-------------------- 1; Mail-Transport-4.01/lib/Mail/Transport/SMTP.pm0000644000175000001440000001121215117245663021604 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport::SMTP;{ our $VERSION = '4.01'; } use parent 'Mail::Transport::Send'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error notice trace warning/ ]; use Net::SMTP (); use constant CMD_OK => 2; #-------------------- sub init($) { my ($self, $args) = @_; $args->{via} ||= 'smtp'; $args->{port} ||= '25'; my $hosts = $args->{hostname}; unless($hosts) { require Net::Config; $hosts = $Net::Config::NetConfig{smtp_hosts}; undef $hosts unless @$hosts; $args->{hostname} = $hosts; } $self->SUPER::init($args) or return; my $helo = $args->{helo} || eval { require Net::Config; $Net::Config::NetConfig{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'); # Which are the destinations. ! defined $args{To} or warning __x"use option `to' to overrule the destination: `To' refers to a field."; my @to = map $_->address, $self->destinations($message, $args{to}); @to or notice(__x"no addresses found to send the message to, no connection made."), return 1; #### Prepare the message. my $out = ''; open my $fh, '>:raw', \$out; $self->putContent($message, $fh, undisclosed => 0); $out =~ m![\r\n]\z! or $out .= "\r\n"; close $fh; #### Send my $server; if(wantarray) { # In LIST context $server = $self->contactAnyServer or return (0, 500, "Connection Failed", "CONNECT", 0); $server->mail($from, %send_options) or return (0, $server->code, $server->message, 'FROM', $server->quit); foreach (@to) { next if $server->to($_); #??? must we be able to disable this? f.i: #??? next if $args{ignore_erroneous_destinations} return (0, $server->code, $server->message, "To $_", $server->quit); } my $bodydata = $message->body->file; $server->datafast(\$out) #!! destroys $out or return (0, $server->code, $server->message, 'DATA', $server->quit); my $accept = ($server->message)[-1]; chomp $accept; my $rc = $server->quit; return ($rc, $server->code, $server->message, 'QUIT', $rc, $accept); } # in SCALAR context $server = $self->contactAnyServer or return 0; $server->mail($from, %send_options) or ($server->quit, return 0); foreach (@to) { next if $server->to($_); $server->quit; return 0; } $server->datafast(\$out) #!! destroys $out or ($server->quit, return 0); $server->quit; } # Improvement on Net::CMD::datasend(), mainly bulk adding dots and avoiding copying # About 79% performance gain on huge messages. # Be warned: this method destructs the content of $data! sub Net::SMTP::datafast($) { my ($self, $data) = @_; $self->_DATA or return 0; $$data =~ tr/\r\n/\015\012/ if "\r" ne "\015"; # mac $$data =~ s/(? crlf as sep. Needed? $$data =~ s/^\./../; # data starts with a dot, escape it $$data =~ s/\012\./\012../g; # other lines which start with a dot $self->_syswrite_with_timeout($$data . ".\015\012"); $self->response == CMD_OK; } #-------------------- sub contactAnyServer() { my $self = shift; my ($enterval, $count, $timeout) = $self->retry; my ($host, $port, $username, $password) = $self->remoteHost; my @hosts = ref $host ? @$host : $host; my $opts = $self->{MTS_net_smtp_opts}; foreach my $host (@hosts) { my $server = $self->tryConnectTo($host, Port => $port, %$opts, Timeout => $timeout) or next; trace "opened SMTP connection to $host."; if(defined $username) { unless($server->auth($username, $password)) { error __x"authentication for {host} failed.", host => $host; return undef; } trace "$host: Authentication succeeded."; } return $server; } undef; } sub tryConnectTo($@) { my ($self, $host) = (shift, shift); Net::SMTP->new($host, @_); } 1; Mail-Transport-4.01/lib/Mail/Transport/Receive.pod0000644000175000001440000000713715117245664022565 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 $class-EB(%options) Inherited, see L =back =head2 Attributes Extends L<"Attributes" in Mail::Transport|Mail::Transport/"Attributes">. =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() 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 Error: Avoid program abuse: specify an absolute path for $program. Specifying explicit locations for executables of email transfer agents should only be done with absolute file names, to avoid various pontential security problems. Cast by C =item Error: Executable $program does not exist. The explicitly indicated mail transfer agent does not exists. The normal settings are used to find the correct location. Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport.pod0000644000175000001440000001442315117245664021177 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. B This module versions 4.00 and up is not fully compatible with older releases: mainly the exception handling has changed. When you need to upgrade, please read F B and may see new releases as well. 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 $class-EB(%options) Inherited, see L -Option --Default executable undef hostname 'localhost' interval 30 password undef port undef proxy undef retry timeout 120 username undef via 'sendmail' =over 2 =item executable => $file 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 => $host|\@hosts The C<$host> on which the server runs. Some protocols accept an ARRAY of alternatives for this option. =item interval => $span The time C<$span> between tries to contact the remote server for sending or receiving a message in seconds. This number must be larger than 0. =item password => $password Some protocols require a C<$password> to be given, usually in combination with a password. =item port => $port The C<$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 C<$path>) of your mail delivery software. =item retry => $count|undef The number of retries before the sending will fail. If C, the number of retries is unlimited. =item timeout => $span The maximim seconds to wait for establishing the connection to a remote server. =item username => $username 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 distribution L. For C or C, install L. =back =back =head2 Attributes Extends L<"Attributes" in Mail::Reporter|Mail::Reporter/"Attributes">. =head2 Server connection =over 4 =item $obj-EB( $name, [@directories] ) Look for a binary with the specified C<$name> in the directories which are defined to be safe. The list of standard directories is followed by the optional C<@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() 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 Error: Avoid program abuse: specify an absolute path for $program. Specifying explicit locations for executables of email transfer agents should only be done with absolute file names, to avoid various pontential security problems. Cast by C =item Error: Executable $program does not exist. The explicitly indicated mail transfer agent does not exists. The normal settings are used to find the correct location. Cast by C =item Error: class $package does not implement method $method. Fatal error: the specific C<$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. Cast by C =back =head1 SEE ALSO This module is part of Mail-Transport version 4.01, built on December 13, 2025. Website: F =head1 LICENSE For contributors see file ChangeLog. This software is copyright (c) 2001-2025 by Mark Overmeer. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Mail-Transport-4.01/lib/Mail/Transport.pm0000644000175000001440000000512415117245663021026 0ustar00markovusers00000000000000# This code is part of Perl distribution Mail-Transport version 4.01. # The POD got stripped from this file by OODoc version 3.05. # For contributors see file ChangeLog. # This software is copyright (c) 2001-2025 by Mark Overmeer. # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later package Mail::Transport;{ our $VERSION = '4.01'; } use parent 'Mail::Reporter'; use strict; use warnings; use Log::Report 'mail-transport', import => [ qw/__x error panic/ ]; use File::Spec (); #-------------------- my %mailers = ( exim => '::Exim', imap => '::IMAP4', imap4 => '::IMAP4', mail => '::Mailx', mailx => '::Mailx', pop => '::POP3', pop3 => '::POP3', postfix => '::Sendmail', qmail => '::Qmail', sendmail => '::Sendmail', smtp => '::SMTP' ); sub new(@) { my $class = shift; $class eq __PACKAGE__ || $class eq "Mail::Transport::Send" or return $class->SUPER::new(@_); # auto restart by creating the right transporter. my %args = @_; my $via = lc($args{via} // '') or panic "no transport protocol provided"; $via = 'Mail::Transport'.$mailers{$via} if exists $mailers{$via}; eval "require $via"; $@ ? undef : $via->new(@_); } sub init($) { my ($self, $args) = @_; $self->SUPER::init($args); $self->{MT_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; File::Spec->file_name_is_absolute($exec) or error __x"avoid program abuse: specify an absolute path for {program}.", program => $exec; -x $exec or error __x"executable {program} does not exist.", program => $exec; } $self; } #-------------------- sub remoteHost() { @{$_[0]}{ qw/MT_hostname MT_port MT_username MT_password/ } } sub retry() { @{$_[0]}{ 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-4.01/Makefile.PL0000644000175000001440000000357615117245663017027 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; require 5.016; use IO::Handle; # Use command 'oodist' to produce your whole software release. my $version = '4.01'; my $git = "https://github.com/markov2/perl5-Mail-Transport"; my $publish = "../public_html/mail-transport"; my $homepage = "http://perl.overmeer.net/CPAN/"; my %oodist = ( oodoc_version => 3.05, first_year => 2001, email => "markov\@cpan.org", include => [ '../Mail-Box-IMAP4', '../Mail-Box-POP3', '../Mail-Message', ], use => [ ], parser => { syntax => 'markov', skip_links => [ ], pmhead => undef, }, tests => { }, release => { publish => "$publish/source", }, raw => { publish => "$publish/raw", }, generate => [ { format => 'pod3', podtail => undef, }, ], ); my %requires = ( 'Carp' => 0, 'Errno' => 0, 'File::Spec' => 0.7, 'IO::Socket' => 0, 'List::Util' => 0, 'Log::Report' => 1.42, 'Net::SMTP' => 0, 'String::Print' => 1.01, 'Mail::Reporter' => '4.00', ); my %optional; WriteMakefile NAME => 'Mail::Transport', VERSION => $version, AUTHOR => 'Mark Overmeer', ABSTRACT => 'Email message exchange', LICENSE => 'perl_5', META_MERGE => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => "$git.git", web => $git, }, bugtracker => { web => "$git/issues", }, homepage => $homepage, license => [ 'http//dev.perl.org/licenses/' ], }, prereqs => { runtime => { requires => \%requires, recommends => \%optional, }, develop => { requires => { 'OODoc' => '3.00', }, }, test => { requires => { 'Test::More' => 1.00, 'Test::Pod' => 1.00, }, }, }, # You may use multiple set-ups, see "oodist --make" x_oodist => \%oodist, }; Mail-Transport-4.01/t/0000755000175000001440000000000015117245665015307 5ustar00markovusers00000000000000Mail-Transport-4.01/t/001use.t0000644000175000001440000000163315117242752016506 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-4.01/README.md0000644000175000001440000000462315117242752016322 0ustar00markovusers00000000000000# distribution Mail-Transport * My extended documentation: * Development via GitHub: * Sponsor me: * Download from CPAN: * Indexed from CPAN: 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. ## Installing 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 ``` **Be aware that version 4 is not fully compatible with releases pre-4** See ## 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. ## 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-4.01/ChangeLog0000644000175000001440000000402715117245663016617 0ustar00markovusers00000000000000 ===== Revision history of Mail-Transport All changes are made by Mark Overmeer unless explicitly stated differently. #!!! Mail::Box 3 compatibility is still maintained on github in branch #!!! maint3, and published. So: you may find newer versions with major #!!! number 3. Use (at least) version 4 for new developments. #!!! Convert? See https://github.com/markov2/perl5-Mail-Box/wiki/ version 4.01: Sat 13 Dec 12:18:33 CET 2025 Fixes: - three messages logged the old way. version 4.00: Thu 11 Dec 13:42:25 CET 2025 Changes: - use Mail::Box 4 exception model: use Log::Report - remove Carp version 3.008: Improvements: - convert install to OODoc 3.05 - restyle code to OODoc 3 standard - explicitly depend on Mail::Message v3, not 4 version 3.007: Wed 3 Sep 10:47:04 CEST 2025 Fixes: - smtp when the message body does not naturally end on a blank. version 3.006: Thu 21 Aug 10:23:14 CEST 2025 Changes: - MailBox mid-life upgrade: require Perl minimal version 5.16 Improvements: - ::SMTP 30% faster, 73% less computer power - add .gitignore - do not use bareword file-handles anymore. - use defined-or version 3.005: Wed 22 Jul 10:40:05 CEST 2020 Improvements: - warn to use ::SMTP, not ::SendMail on bulk messages. - much lower elapse time on ::SMTP (local?) delivery. version 3.004: Fri 3 May 09:29:07 CEST 2019 Improvements: - add imap/imap4 version 3.003: Mon 3 Sep 08:16:23 CEST 2018 Fixes: - fix metadata [Mohammad S Anwar] - add pod testing - use of NetConfig Improvements: - return dataend() message to ::SMTP::trySend(), which may contain the message-id. [Andy Beverley] version 3.002: Wed 24 Jan 16:02:02 CET 2018 Improvements: - convert to GIT - publish on GitHUB - fix license to "as perl" rt.cpan.org#120319 [Jitka Plesnikova] 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-4.01/MANIFEST0000644000175000001440000000124715117245665016201 0ustar00markovusers00000000000000ChangeLog MANIFEST Makefile.PL 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 xt/99pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Mail-Transport-4.01/xt/0000755000175000001440000000000015117245665015477 5ustar00markovusers00000000000000Mail-Transport-4.01/xt/99pod.t0000644000175000001440000000041215117242752016617 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use Test::More; BEGIN { eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; plan skip_all => "devel home uses OODoc" if $ENV{MARKOV_DEVEL}; } all_pod_files_ok(); Mail-Transport-4.01/META.yml0000644000175000001440000000246415117245665016323 0ustar00markovusers00000000000000--- abstract: 'Email message exchange' author: - 'Mark Overmeer' build_requires: ExtUtils::MakeMaker: '0' Test::More: '1' Test::Pod: '1' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.76, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Mail-Transport no_index: directory: - t - inc recommends: {} requires: Carp: '0' Errno: '0' File::Spec: '0.7' IO::Socket: '0' List::Util: '0' Log::Report: '1.42' Mail::Reporter: '4.00' Net::SMTP: '0' String::Print: '1.01' resources: bugtracker: https://github.com/markov2/perl5-Mail-Transport/issues homepage: http://perl.overmeer.net/CPAN/ repository: https://github.com/markov2/perl5-Mail-Transport.git version: '4.01' x_oodist: email: markov@cpan.org first_year: 2001 generate: - format: pod3 podtail: ~ include: - ../Mail-Box-IMAP4 - ../Mail-Box-POP3 - ../Mail-Message oodoc_version: 3.05 parser: pmhead: ~ skip_links: [] syntax: markov raw: publish: ../public_html/mail-transport/raw release: publish: ../public_html/mail-transport/source tests: {} use: [] x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Mail-Transport-4.01/META.json0000644000175000001440000000462715117245665016476 0ustar00markovusers00000000000000{ "abstract" : "Email message exchange", "author" : [ "Mark Overmeer" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.76, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "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" } }, "develop" : { "requires" : { "OODoc" : "3.00" } }, "runtime" : { "recommends" : {}, "requires" : { "Carp" : "0", "Errno" : "0", "File::Spec" : "0.7", "IO::Socket" : "0", "List::Util" : "0", "Log::Report" : "1.42", "Mail::Reporter" : "4.00", "Net::SMTP" : "0", "String::Print" : "1.01" } }, "test" : { "requires" : { "Test::More" : "1", "Test::Pod" : "1" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/markov2/perl5-Mail-Transport/issues" }, "homepage" : "http://perl.overmeer.net/CPAN/", "repository" : { "type" : "git", "url" : "https://github.com/markov2/perl5-Mail-Transport.git", "web" : "https://github.com/markov2/perl5-Mail-Transport" } }, "version" : "4.01", "x_oodist" : { "email" : "markov@cpan.org", "first_year" : 2001, "generate" : [ { "format" : "pod3", "podtail" : null } ], "include" : [ "../Mail-Box-IMAP4", "../Mail-Box-POP3", "../Mail-Message" ], "oodoc_version" : 3.05, "parser" : { "pmhead" : null, "skip_links" : [], "syntax" : "markov" }, "raw" : { "publish" : "../public_html/mail-transport/raw" }, "release" : { "publish" : "../public_html/mail-transport/source" }, "tests" : {}, "use" : [] }, "x_serialization_backend" : "JSON::PP version 4.16" }