Mail::Mailer(3)

πŸ’Œ Mail::Mailer β€” aka the "send simple emails" king πŸ‘‘

okay so bestie, this is Mail::Mailer, from the User Contributed Perl Documentation crew (perl v5.42.0, dated 2024-12-12, iykyk). It sends mail. Simple emails. That's the whole vibe. Let's get into it πŸŽ€


✨ NAME ✨

Mail::Mailer β€” send simple emails πŸ’…


🌸 INHERITANCE 🌸

so it's giving nepo baby, but make it class hierarchy:

Mail::Mailer
  is an IO::Handle

πŸ¦‹ SYNOPSIS πŸ¦‹

the way you literally just… use it:

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

πŸ’– DESCRIPTION πŸ’–

It sends mail using any of the built-in methods. As the TYPE argument to new(), you can specify any of these icons 🌈:

  • "sendmail" β€” uses the sendmail program to deliver the mail. classic. iconic. no notes.
  • "smtp" β€” uses the smtp protocol via Net::SMTP to deliver the mail. The server you wanna use can be specified in @args like:
$mailer = Mail::Mailer->new('smtp', Server => $server);

okay so heads up 🫢: the smtp mailer does not handle Cc and Bcc lines, neither their Resent-* fellows (rude, I know). But the Debug options enables debugging output from Net::SMTP, so you can peek at what's happening πŸ‘€

[added 2.21] You may also use the StartTLS => 1 options to upgrade the connection with STARTTLS. The same for option SSL => 1. secure-ish era ✨

You may also use the Auth => [ $user, $password ] option for SASL authentication. To make this work, you have to install the Authen::SASL distribution yourself β€” it is not automatically installed. yes, that means you. go install it. πŸ™ˆ

  • "smtps" β€” this option is deprecated when you have libnet 1.28 (2014) and above πŸ’€

Otherwise: 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" β€” uses qmail's qmail-inject program to deliver the mail. retro moment πŸŽ€
  • "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. literally just vibes into a file 🌸

"Mail::Mailer" will search for executables in the above order. The default mailer will be the first one found. first come, first slay πŸ‘‘


πŸ’… METHODS πŸ’…

🧚 Constructors 🧚

  • Mail::Mailer->new($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. straightforward. we love that.
  • $obj->open(HASH) β€” the HASH consists of key and value pairs, the key being the name of the header field (eg, "To"), and the value being the corresponding contents of the header field. The value can either be a scalar (eg, "gnat@frii.com") or a reference to an array of scalars ("eg, ['gnat@frii.com', 'Tim.Bunce@ig.co.uk']"). so flexible of you, header πŸ’–

πŸ”₯ DETAILS πŸ”₯

🌈 ENVIRONMENT VARIABLES 🌈

  • 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"

(yes the c:/ thing is real. windows girlies rise 🫢)

πŸ’€ BUGS πŸ’€

Not me having to say this but: 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. so like, sanitize your input, bestie. no cap. 🚨

fr fr, don't feed it untrusted header values and expect it to save you πŸ™ˆ

⭐ SEE ALSO ⭐

This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. go visit, she's gorgeous ✨


πŸ‘‘ AUTHORS πŸ‘‘

The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. (respect the handoff 🫑)

  • Mail::Cap by Gisle Aas <aas@oslonett.no>.
  • Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>.
  • Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>.

For other contributors see ChangeLog. shoutout to the whole group chat πŸŽ€


πŸ“ LICENSE πŸ“

Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2024 Mark Overmeer <perl@overmeer.net>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html. legal slay πŸ’œ


and that's the whole page, bestie πŸ¦‹ mwah πŸ’‹ β€” this lil beauty is perl v5.42.0, dated 2024-12-12, and it's the Mail::Mailer(3) manpage. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from