=encoding utf8 =head1 NAME Mail::Mailer - send simple emails =head1 INHERITANCE Mail::Mailer is an IO::Handle =head1 SYNOPSIS use Mail::Mailer; use Mail::Mailer qw(mail); # specifies default mailer $mailer = Mail::Mailer->new; $mailer = Mail::Mailer->new($type, @args); $mailer->open(\%headers); print $mailer $body; $mailer->close or die "couldn't send whole message: $!\n"; =head1 DESCRIPTION Sends mail using any of the built-in methods. As TYPE argument to L, you can specify any of =over 4 =item C Use the C program to deliver the mail. =item C Use the C protocol via Net::SMTP to deliver the mail. The server to use can be specified in C<@args> with $mailer = Mail::Mailer->new('smtp', Server => $server); The smtp mailer does not handle C and C lines, neither their C fellows. The C options enables debugging output from C. You may also use the C<< Auth => [ $user, $password ] >> option for SASL authentication. To make this work, you have to install the L distribution yourself: it is not automatically installed. =item C Use the smtp over ssl protocol via L to deliver the mail. Usage is identical to C. You have to install Authen::SASL as well. $mailer = Mail::Mailer->new('smtps', Server => $server); =item C Use qmail's qmail-inject program to deliver the mail. =item C Used for debugging, this displays the data to the file named in C<$Mail::Mailer::testfile::config{outfile}> which defaults to a file named C. No mail is ever sent. =back C will search for executables in the above order. The default mailer will be the first one found. =head1 METHODS =head2 Constructors =over 4 =item Mail::Mailer-EB($type, %options) The $type is one of the back-end sender implementations, as described in the DESCRIPTION chapter of this manual page. The %options are passed to that back-end. =item $obj-EB(HASH) The HASH consists of key and value pairs, the key being the name of the header field (eg, C), and the value being the corresponding contents of the header field. The value can either be a scalar (eg, C) or a reference to an array of scalars (C<< eg, ['gnat@frii.com', 'Tim.Bunce@ig.co.uk'] >>). =back =head1 DETAILS =head2 ENVIRONMENT VARIABLES =over 4 =item PERL_MAILERS Augments/override the build in choice for binary used to send out our mail messages. Format: "type1:mailbinary1;mailbinary2;...:type2:mailbinaryX;...:..." Example: assume you want you use private sendmail binary instead of mailx, one could set C to: "mail:/does/not/exists:sendmail:$HOME/test/bin/sendmail" On systems which may include C<:> in file names, use C<|> as separator between type-groups. "mail:c:/does/not/exists|sendmail:$HOME/test/bin/sendmail" =back =head2 BUGS Mail::Mailer does not help with folding, and does not protect against various web-script hacker attacks, for instance where a new-line is inserted in the content of the field. =head1 SEE ALSO This module is part of the MailTools distribution, F. =head1 AUTHORS The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas Eaas@oslonett.noE. Mail::Field::AddrList by Peter Orbaek Epoe@cit.dkE. Mail::Mailer and Mail::Send by Tim Bunce ETim.Bunce@ig.co.ukE. For other contributors see ChangeLog. =head1 LICENSE Copyrights 1995-2000 Graham Barr Egbarr@pobox.comE and 2001-2017 Mark Overmeer Eperl@overmeer.netE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F