Mail::Send(3)
π Mail::Send(3) β like, the whole manual page, bestie
Okay so this is Mail::Send(3), from the User Contributed Perl Documentation crew β yes, a real Perl manpage, and yes, we're gonna get through it together. Grab a strawberry drink π, we're going in.
β¨ NAME β¨
Mail::Send β a simple electronic mail interface. That's it, that's the whole vibe. π
π SYNOPSIS π
Like, here's the whole thing in code, no cap, character for character:
require Mail::Send;
$msg = Mail::Send->new;
$msg = Mail::Send->new(Subject => 'example', To => 'timbo');
$msg->to('user@host');
$msg->to('user@host', 'user2@example.com');
$msg->subject('example subject');
$msg->cc('user@host');
$msg->bcc('someone@else');
$msg->set($header, @values);
$msg->add($header, @values);
$msg->delete($header);
# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.
# Arguments to the open() method are passed to the Mail::Mailer
# constructor.
$fh = $msg->open; # some default mailer
$fh = $msg->open('sendmail'); # explicit
print $fh "Body of message";
$fh->close # complete the message and send it
or die "couldn't send whole message: $!\n";
I know, I know β that or die "couldn't send whole message: $!\n" is giving main character energy. Obsessed. π₯
πΈ DESCRIPTION πΈ
So Mail::Send builds e-mail messages without using any of the Mail::Header knowledge. Which meansβ¦ yeah. All the escaping and folding? That's on you, bestie. π
Also: do not forget to escape leading dots. Simplicity has its price, and the price is your own sanity. π
When you have time (and honestly, make time), take a look at Mail::Transport, which is part of the MailBox suite. It's giving β¨upgradeβ¨, iykyk.
π¦ METHODS π¦
π Constructors π
Mail::Send->new(PAIRS)β You can pass a list of header fields (as key-valuePAIRS) to initialize the object, but it's lowkey limited to just the few that exist as methods:"to","subject","cc", and"bcc". For any other header fields? Useadd(). That's the whole rule. π«Ά
π Header fields π
$obj->add($fieldname, @values)β Adds values onto the list of already-defined values for the$fieldname. It stacks, it doesn't replace. π
Then the little squad that hangs out together:
$obj->bcc(@values)$obj->cc(@values)$obj->delete($fieldname)$obj->set($fieldname, @values)β the@valueshere will replace the old values for the$fieldname. And what comes back to you? The LIST of values after the modification. Cute, right? π$obj->subject(@values)$obj->to(@values)
π Sending π
$obj->open(%options)β The%optionsget used to initiate a mailer object viaMail::Mailer::new(). ThenMail::Mailer::open()is called with all the knowledge collected in thisMail::Sendobject. Teamwork, honestly. π«Ά
β οΈ Be warned, bestie: this module implements raw smtp, which means you have to escape any lines that start with a dot β by adding one in front. Not me forgetting that and then crying about it. π
β SEE ALSO β
This module is part of the MailTools distribution: http://perl.overmeer.net/mailtools/ β bookmark it, it's iconic.
π§ AUTHORS π§
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance β without commitment to further development, so, like, no promises. π
Mail::Capby Gisle Aas<aas@oslonett.no>Mail::Field::AddrListby Peter Orbaek<poe@cit.dk>Mail::MailerandMail::Sendby Tim Bunce<Tim.Bunce@ig.co.uk>- For other contributors, see
ChangeLog. π
π 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 for the details, bestie. π
Okay that's the whole page! Slay. π β¨
Signing off with love: this is from perl v5.42.0, dated 2024-12-12 β and it's literally Mail::Send(3), periodt. π¦π
π¦ where this page comes from
- opensuse-leap 16.0: perl-MailTools 2.220.0-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms