man Mail::Mailer () - Simple interface to electronic mailing mechanisms


Mail::Mailer - Simple interface to electronic mailing mechanisms


    use Mail::Mailer;
    use Mail::Mailer qw(mail);

    $mailer = new Mail::Mailer;

    $mailer = new Mail::Mailer $type, @args;


    print $mailer $body;



Sends mail using any of the built-in methods. You can alter the behaviour of a method by passing CW$command to the CWnew method. Use the CWsendmail program to deliver the mail. CW$command is the path to CWsendmail. Use qmail's qmail-inject program to deliver the mail. Use the CWsmtp protocol via Net::SMTP to deliver the mail. The server to use can be specified in CW@args with

    $mailer = new Mail::Mailer 'smtp', Server => $server;
The smtp mailer does not handle CWCc and CWBcc lines, neither their CWResent-* fellows. The CWDebug options enables debugging output from CWNet::SMTP. Use qmail's qmail-inject program to deliver the mail. Used for debugging, this displays the data on STDOUT. No mail is ever sent. CW$command is ignored.

CWMail::Mailer will search for executables in the above order. The default mailer will be the first one found.


CWnew can optionally be given a CW$command and CW$type. CW$type is one CWsendmail, CWmail, ... given above. The meaning of CW$command depends on CW$type.

CWopen is given a reference to a hash. The hash consists of key and value pairs, the key being the name of the header field (eg, CWTo), and the value being the corresponding contents of the header field. The value can either be a scalar (eg, or a reference to an array of scalars (CWeg, ['', '']).


Assist formatting of fields in ...::rfc822:send_headers to ensure valid in the face of newlines and longlines etc.

Secure all forms of send_headers() against hacker attack and invalid contents. Especially \n~... in ...::mail::send_headers.


Augments/override the build in choice for binary used to send out our mail messages. Format:
Example: assume you want you use private sendmail binary instead of mailx, one could set CWPERL_MAILERS to:
On systems which may include CW: in file names, use CW| as separator between type-groups.




Maintained by Mark Overmeer <>

Original code written by Tim Bunce <>, with a kick start from Graham Barr <>. With contributions by Gerard Hickey <> Small fix and documentation by Nathan Torkington <>.