man-pages/man3/Mail::Mailer.3pm.html
2021-03-31 01:06:50 +01:00

333 lines
6.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Mail::Mailer</TITLE>
</HEAD><BODY>
<H1>Mail::Mailer</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-07-25<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Mail::Mailer - send simple emails
<A NAME="lbAC">&nbsp;</A>
<H2>INHERITANCE</H2>
<PRE>
Mail::Mailer
is an IO::Handle
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use Mail::Mailer;
use Mail::Mailer qw(mail); # specifies default mailer
$mailer = Mail::Mailer-&gt;new;
$mailer = Mail::Mailer-&gt;new($type, @args);
$mailer-&gt;open(\%headers);
print $mailer $body;
$mailer-&gt;close
or die &quot;couldn't send whole message: $!\n&quot;;
</PRE>
<A NAME="lbAE">&nbsp;</A>
<H2>DESCRIPTION</H2>
Sends mail using any of the built-in methods. As <FONT SIZE="-1">TYPE</FONT> argument
to <B>new()</B>, you can specify any of
<DL COMPACT>
<DT id="1">&quot;sendmail&quot;<DD>
Use the <TT>&quot;sendmail&quot;</TT> program to deliver the mail.
<DT id="2">&quot;smtp&quot;<DD>
Use the <TT>&quot;smtp&quot;</TT> protocol via Net::SMTP to deliver the mail. The server
to use can be specified in <TT>@args</TT> with
<P>
<PRE>
$mailer = Mail::Mailer-&gt;new('smtp', Server =&gt; $server);
</PRE>
<P>
The smtp mailer does not handle <TT>&quot;Cc&quot;</TT> and <TT>&quot;Bcc&quot;</TT> lines, neither their
<TT>&quot;Resent-*&quot;</TT> fellows. The <TT>&quot;Debug&quot;</TT> options enables debugging output
from <TT>&quot;Net::SMTP&quot;</TT>.
<P>
[added 2.21] You may also use the <TT>&quot;StartTLS =&gt; 1&quot;</TT> options to upgrade the
connection with <FONT SIZE="-1">STARTTLS.</FONT> You need <TT>&quot;libnet&quot;</TT> version 1.28 (2014) for this
to work.
<P>
You may also use the <TT>&quot;Auth =&gt; [ $user, $password ]&quot;</TT> option for <FONT SIZE="-1">SASL</FONT>
authentication. To make this work, you have to install the Authen::SASL
distribution yourself: it is not automatically installed.
<DT id="3">&quot;smtps&quot;<DD>
This option is <B>deprecated</B> when you have <TT>&quot;libnet&quot;</TT> 1.28 (2014) and above.
<P>
Use the smtp over ssl protocol via Net::SMTP::SSL to deliver the mail.
Usage is identical to <TT>&quot;smtp&quot;</TT>. You have to install Authen::SASL as
well.
<P>
<PRE>
$mailer = Mail::Mailer-&gt;new('smtps', Server =&gt; $server);
</PRE>
<DT id="4">&quot;qmail&quot;<DD>
Use qmail's qmail-inject program to deliver the mail.
<DT id="5">&quot;testfile&quot;<DD>
Used for debugging, this displays the data to the file named in
<TT>$Mail::Mailer::testfile::config{outfile}</TT> which defaults to a file
named <TT>&quot;mailer.testfile&quot;</TT>. No mail is ever sent.
</DL>
<P>
<TT>&quot;Mail::Mailer&quot;</TT> will search for executables in the above order. The
default mailer will be the first one found.
<A NAME="lbAF">&nbsp;</A>
<H2>METHODS</H2>
<A NAME="lbAG">&nbsp;</A>
<H3>Constructors</H3>
<DL COMPACT>
<DT id="6">Mail::Mailer-&gt;<B>new</B>($type, %options)<DD>
The <TT>$type</TT> is one of the back-end sender implementations, as described in
the <FONT SIZE="-1">DESCRIPTION</FONT> chapter of this manual page. The <TT>%options</TT> are passed to
that back-end.
<DT id="7">$obj-&gt;<B>open</B>(<FONT SIZE="-1">HASH</FONT>)<DD>
The <FONT SIZE="-1">HASH</FONT> consists of key and value pairs, the key being the name of
the header field (eg, <TT>&quot;To&quot;</TT>), and the value being the corresponding
contents of the header field. The value can either be a scalar
(eg, <TT>&quot;<A HREF="mailto:gnat@frii.com">gnat@frii.com</A>&quot;</TT>) or a reference to an array of scalars
(<TT>&quot;eg, ['<A HREF="mailto:gnat@frii.com">gnat@frii.com</A>', '<A HREF="mailto:Tim.Bunce@ig.co.uk">Tim.Bunce@ig.co.uk</A>']&quot;</TT>).
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>DETAILS</H2>
<A NAME="lbAI">&nbsp;</A>
<H3><FONT SIZE="-1">ENVIRONMENT VARIABLES</FONT></H3>
<DL COMPACT>
<DT id="8"><FONT SIZE="-1">PERL_MAILERS</FONT><DD>
Augments/override the build in choice for binary used to send out
our mail messages.
<P>
Format:
<P>
<PRE>
&quot;type1:mailbinary1;mailbinary2;...:type2:mailbinaryX;...:...&quot;
</PRE>
<P>
Example: assume you want you use private sendmail binary instead
of mailx, one could set <TT>&quot;PERL_MAILERS&quot;</TT> to:
<P>
<PRE>
&quot;mail:/does/not/exists:sendmail:$HOME/test/bin/sendmail&quot;
</PRE>
<P>
On systems which may include <TT>&quot;:&quot;</TT> in file names, use <TT>&quot;|&quot;</TT> as separator
between type-groups.
<P>
<PRE>
&quot;mail:c:/does/not/exists|sendmail:$HOME/test/bin/sendmail&quot;
</PRE>
</DL>
<A NAME="lbAJ">&nbsp;</A>
<H3><FONT SIZE="-1">BUGS</FONT></H3>
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.
<A NAME="lbAK">&nbsp;</A>
<H2>SEE ALSO</H2>
This module is part of the MailTools distribution,
<I><A HREF="http://perl.overmeer.net/mailtools/">http://perl.overmeer.net/mailtools/</A></I>.
<A NAME="lbAL">&nbsp;</A>
<H2>AUTHORS</H2>
The MailTools bundle was developed by Graham Barr. Later, Mark
Overmeer took over maintenance without commitment to further development.
<P>
Mail::Cap by Gisle Aas &lt;<A HREF="mailto:aas@oslonett.no">aas@oslonett.no</A>&gt;.
Mail::Field::AddrList by Peter Orbaek &lt;<A HREF="mailto:poe@cit.dk">poe@cit.dk</A>&gt;.
Mail::Mailer and Mail::Send by Tim Bunce &lt;<A HREF="mailto:Tim.Bunce@ig.co.uk">Tim.Bunce@ig.co.uk</A>&gt;.
For other contributors see ChangeLog.
<A NAME="lbAM">&nbsp;</A>
<H2>LICENSE</H2>
Copyrights 1995-2000 Graham Barr &lt;<A HREF="mailto:gbarr@pobox.com">gbarr@pobox.com</A>&gt; and
2001-2017 Mark Overmeer &lt;<A HREF="mailto:perl@overmeer.net">perl@overmeer.net</A>&gt;.
<P>
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See <I><A HREF="http://www.perl.com/perl/misc/Artistic.html">http://www.perl.com/perl/misc/Artistic.html</A></I>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
<DT id="10"><A HREF="#lbAC">INHERITANCE</A><DD>
<DT id="11"><A HREF="#lbAD">SYNOPSIS</A><DD>
<DT id="12"><A HREF="#lbAE">DESCRIPTION</A><DD>
<DT id="13"><A HREF="#lbAF">METHODS</A><DD>
<DL>
<DT id="14"><A HREF="#lbAG">Constructors</A><DD>
</DL>
<DT id="15"><A HREF="#lbAH">DETAILS</A><DD>
<DL>
<DT id="16"><A HREF="#lbAI"><FONT SIZE="-1">ENVIRONMENT VARIABLES</FONT></A><DD>
<DT id="17"><A HREF="#lbAJ"><FONT SIZE="-1">BUGS</FONT></A><DD>
</DL>
<DT id="18"><A HREF="#lbAK">SEE ALSO</A><DD>
<DT id="19"><A HREF="#lbAL">AUTHORS</A><DD>
<DT id="20"><A HREF="#lbAM">LICENSE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:47 GMT, March 31, 2021
</BODY>
</HTML>