Mail::Verify(3pm)

πŸ“¦
version 0.02 Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’Œ Mail::Verify β€” the perl manual page, bestie edition ✨

okay so this is Mail::Verify(3pm) from the User Contributed Perl Documentation section of the manual, and it is literally your new best friend for checking if an email address is real. no cap. πŸ¦‹


🌸 NAME 🌸

Mail::Verify β€” a utility to verify an email address πŸ’…


✨ SYNOPSIS ✨

use Mail::Verify;

that's it. that's the whole vibe check. πŸŽ€


πŸ’– DESCRIPTION πŸ’–

so Mail::Verify gives you a CheckAddress function, and its whole job is verifying email addresses. it's giving detective energy. πŸ”

here's the order of operations, bestie, and it matters:

  1. first it checks the syntax of the email address. like, does this even look like an email.
  2. then it verifies there's at least one valid MX server that's actually accepting email for that domain. because a pretty address means nothing if nobody's home. 😭

and to do that second part, it uses Net::DNS and IO::Socket β€” it pulls a list of MX records (or, if that doesn't work out, it falls back on a host's A record) and checks them to make sure at least one SMTP server is out here accepting connections. periodt. πŸ‘‘


🌈 ERRORS 🌈

here's the list of return codes and what they mean, and honestly this part is important so read it fr fr:

  • 0 β€” the email address appears to be valid. slay!! πŸŽ‰
  • 1 β€” no email address was supplied. bestie. you gave it nothing. πŸ’€
  • 2 β€” there is a syntaxical error in the email address.
  • 3 β€” there are no DNS entries for the host in question (no MX records and no A records). the domain is giving ghost town. πŸ‘»
  • 4 β€” there are no live SMTP servers accepting connections for this email address. so sad, nobody answered the door. 😭

🫢 EXAMPLES 🫢

this example shows obtaining an email address from a form field and verifying it. classic main character move.

use CGI qw/:standard/;
use Mail::Verify;
my $q = new CGI;
[...]
my $email = $q->param("emailaddr");
my $email_ck = Mail::Verify::CheckAddress( $email );
if( $email_ck ) {
    print '<h1>Form input error: Invalid email address.</h1>';
}
[...]

see how if the check comes back truthy it prints the form input error? yeah. iconic. πŸŽ€


πŸ™ˆ POD ERRORS πŸ™ˆ

hey! so the document above had some coding errors, and they're explained below. not me snitching on the docs but okay. πŸ’…

  • Around line 30:
    • '=item' outside of any '=over'
  • Around line 34:
    • Expected text after =item, not a number
  • Around line 38:
    • Expected text after =item, not a number
  • Around line 42:
    • Expected text after =item, not a number
  • Around line 46:
    • Expected text after =item, not a number
  • Around line 50:
    • You forgot a '=back' before '=head1'
no judgement, we've all forgotten a =back before. 🫢

and that's the whole page, bestie!! this one's from perl v5.36.0, dated 2022-12-05, and it lives in the Mail::Verify(3pm) corner of the manual. go verify some emails and stay hydrated. πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€πŸ’…πŸ«ΆπŸ‘‘

πŸ“¦ where this page comes from