Net::SMTP::TLS(3pm)
π Net::SMTP::TLS β the manual page, bestie edition β¨
okay so you're reading the Net::SMTP::TLS(3pm) page from the User Contributed Perl Documentation? good. sit down. get a snack. π
πΈ NAME πΈ
Net::SMTP::TLS β an SMTP client that supports TLS and AUTH. yes, both. she's versatile like that. π
β¨ VERSION β¨
Version 0.12 π
π SYNOPSIS π
here's the whole vibe in one code block, no edits, exactly as it lives:
use Net::SMTP::TLS;
my $mailer = new Net::SMTP::TLS(
'your.mail.host',
Hello => 'some.host.name',
Port => 25, #redundant
User => 'emailguy',
Password=> 's3cr3t');
$mailer->mail('emailguy@your.mail.host');
$mailer->to('someonecool@somewhere.else');
$mailer->data;
$mailer->datasend("Sent thru TLS!");
$mailer->dataend;
$mailer->quit;
that's literally it. that's the whole send-an-email arc. main character energy from start to finish. π
π DESCRIPTION π
Net::SMTP::TLS is a TLS-capable and AUTH-capable SMTP client, and she serves an interface that you'll already recognize if you've ever hung out with Net::SMTP. it implements a subset of the methods that module gives you β so like, not (yet) a full mirror image of that API, bestie. it's giving "little sister who's still growing into her powers." π¦
the methods Net::SMTP::TLS supports are the ones used in the example up above βοΈ. mostly self-explanatory honestly, but if you're sitting there like "...what", go read the perldoc for Net::SMTP. it's all there.
and here's where the methods differ, so listen up:
- the
mailmethod does not take the options list thatNet::SMTPtakes. - the
tomethod also does not take options, and it is the only method available for setting the recipient β unlike the many synonymsNet::SMTPprovides. one method. one job. she's focused. β¨ - the constructor takes a limited number of
Net::SMTP's parameters. and forNet::SMTP::TLS, the constructor takes the following β plus the hostname of the mail server, which must be the first parameter and is not explicitly named:NoTLSβ in the unlikely event that you need to use this class to do non-TLS SMTP (and honestly? you ought to be usingNet::SMTPitself for that...), this turns TLS off when you supply it a true value. β οΈ warning tho: this will most often cause an error related to authentication when you use it on a server that requires TLS. so. iykyk.Helloβ the hostname used in theEHLOcommand.Portβ the port to connect to the SMTP service (defaults to25).Timeoutβ timeout for the initial socket connection (defaults to5, passed directly toIO::Socket::INET).Userβ username for SMTP AUTH.Passwordβ password for SMTP AUTH.
π TLS and AUTHentication π
when you construct a Net::SMTP::TLS instance, the whole login process happens right then and there. not later. immediately. no waiting around. π
the full sequence goes like this:
- send
EHLOto the server first. - initiate a TLS session through
STARTTLS. - once that's done, the module attempts to log in using the credentials you gave the constructor β if you gave them.
the AUTH method it picks depends on the features the server returns after the EHLO command. based on that, the order of preference is:
CRAM-MD5β used if available.LOGINβ next in line.PLAINβ the fallback.
important tea β:LOGINis the only authentication method that has been tested. theCRAM-MD5andPLAINlogin functionality was taken directly from the script mentioned down in the acknowledgements, but it has not been tested personally. so like, if those don't work, that's... a known thing. π
π¨ ERROR HANDLING π¨
this module will croak whenever an SMTP error happens. that's it, that's the whole thing, it does not sugarcoat. π
if you want to handle it gracefully in your app, wrap your mail transmission in an eval {} block and check $@ afterward. that's the move. that's the escape hatch. π«Ά
π ACKNOWLEDGEMENTS π
real talk: this code was blatantly plagiarized from Michal Ludvig's smtp-client.pl script. see http://www.logix.cz/michal/devel/smtp for his excellent work. credit where credit is due, always. π
π AUTHOR π
Alexander Christian Westholm, awestholm at verizon dawt net
Improvements courtesy of Tomek Zielinski π
and that's the page, bestie!! perl v5.40.1, dated 2025-05-07 β now go send that email the secure way πβ¨ππ¦
π¦ where this page comes from
- debian trixie: libnet-smtp-tls-perl 0.12-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-smtp-tls-perl 0.12-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-smtp-tls-perl 0.12-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms