Mail::Mailer(3) User Contributed Perl Documentation Mail::Mailer(3)

Mail::Mailer - send simple emails

```
  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";
```

Sends mail using any of the built-in methods. As TYPE argument to **new()**, you can specify any of

"sendmail" Use the "sendmail" program to deliver the mail.

"smtp"

Use the "smtp" protocol via Net::SMTP to deliver the mail. The server to use can be specified in @args with

```
 $mailer = Mail::Mailer->new('smtp', Server => $server);
    
```

The smtp mailer does not handle "Cc" and "Bcc" lines, neither their "Resent-\*" fellows. The "Debug" options enables debugging output from "Net::SMTP".

\[added 2.21] You may also use the "StartTLS =&gt; 1" options to upgrade the connection with STARTTLS. The same for option "SSL =&gt; 1".

You may also use the "Auth =&gt; \[ $user, $password ]" option for SASL authentication. To make this work, you have to install the Authen::SASL distribution yourself: it is not automatically installed.

"smtps"

This option is **deprecated** when you have "libnet" 1.28 (2014) and above.

Use the smtp over ssl protocol via Net::SMTP::SSL to deliver the mail. Usage is identical to "smtp". You have to install Authen::SASL as well.

```
 $mailer = Mail::Mailer->new('smtps', Server => $server);
    
```

"qmail"

Use qmail's qmail-inject program to deliver the mail.

"testfile"

Used for debugging, this displays the data to the file named in $Mail::Mailer::testfile::config{outfile} which defaults to a file named "mailer.testfile". No mail is ever sent.

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

[PERL\_MAILERS](#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 "PERL\_MAILERS" to:

```
    "mail:/does/not/exists:sendmail:$HOME/test/bin/sendmail"
    
```

On systems which may include ":" in file names, use "|" as separator between type-groups.

```
    "mail:c:/does/not/exists|sendmail:$HOME/test/bin/sendmail"
    
```

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.

# [POD ERRORS](#POD_ERRORS)

Hey! **The above document had some coding errors, which are explained below:**

[Around line 15:](#Around)

Unknown directive: =chapter

[Around line 19:](#Around~2)

Unknown directive: =chapter

[Around line 32:](#Around~3)

Unknown directive: =chapter

[Around line 34:](#Around~4)

Deleting unknown formatting code M&lt;&gt;

[Around line 44:](#Around~5)

Deleting unknown formatting code M&lt;&gt;

[Around line 64:](#Around~6)

Deleting unknown formatting code M&lt;&gt;

[Around line 85:](#Around~7)

Unknown directive: =chapter

[Around line 87:](#Around~8)

Unknown directive: =section

[Around line 177:](#Around~9)

=cut found outside a pod block. Skipping to next block.

[Around line 209:](#Around~10)

Unknown directive: =method

[Around line 301:](#Around~11)

Unknown directive: =chapter

[Around line 303:](#Around~12)

Unknown directive: =section

[Around line 328:](#Around~13)

Unknown directive: =section

2026-07-15 perl v5.42.2

---

Document: Mail::Mailer(3pm) from perl-mailtools 2.22-r3 (Chainguard OS)
Source: https://github.com/markov2/perl5-MailTools
