Address(3pm)

πŸ“¦
version 0.4 Β· 6 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’Œ Address(3pm) β€” the manual page, bestie edition ✨

okay so you found Address(3pm) in the perl docs and you're like "what is this" β€” don't worry, I got you. It's a User Contributed Perl Documentation page, and it's genuinely so useful, I'm obsessed.


πŸŽ€ NAME πŸŽ€

Mail::RFC822::Address β€” a Perl extension for validating email addresses according to RFC822. That's it. That's the whole job. πŸ’…


✨ SYNOPSIS ✨

here's the vibe, copy-paste ready:

  use Mail::RFC822::Address qw(valid validlist);

  if (valid("pdw@ex-parrot.com")) {
      print "That's a valid address\n";
  }

  if (validlist("pdw@ex-parrot.com, other@elsewhere.com")) {
      print "That's a valid list of addresses\n";
  }

like… look at it. chef's kiss. πŸ˜­πŸ’–


🌸 DESCRIPTION 🌸

So Mail::RFC822::Address validates email addresses against the grammar described in RFC 822, and it does it using regular expressions. slay.

Now, "how do I validate a user-supplied email address" is literally a FAQ β€” check perlfaq9 if you wanna see. And the tea is: the only sure way to know if a supplied email address is genuine is to send an email to it and see if the user actually receives it. no shortcuts, no cap. 😭

But the one useful check you can do on an address is checking that it's syntactically valid. That's what this module does. periodt. πŸ‘‘

This module is functionally equivalent to RFC::RFC822::Address, except it uses regular expressions instead of the Parse::RecDescent parser. and bestie, that means startup time is greatly reduced, which makes it perfect for transient scripts like CGI scripts. iconic behaviour honestly.


πŸ¦‹ valid ( address ) πŸ¦‹

Returns true or false to tell you whether address is an RFC822 valid address. simple as that, she's not complicated. πŸ’…

πŸ¦‹ validlist ( addresslist ) πŸ¦‹

In scalar context, returns true if the parameter is an RFC822 valid list of addresses.

In list context, returns an empty list on failure (meaning an invalid address was found). Otherwise it returns a list whose first element is the number of addresses found, and whose remaining elements are the addresses. 🫢

and why does it do that whole thing? because of the disambiguation, bestie β€” an empty string is a valid list, so it needs a way to tell "failure (invalid)" apart from "success but with no addresses found". the number tells you. iykyk. ✨

πŸ‘‘ AUTHOR πŸ‘‘

Paul Warren, pdw@ex-parrot.com


πŸ’œ CREDITS πŸ’œ

Most of the test suite in test.pl is taken from RFC::RFC822::Address, written by Abigail, abigail@foad.org. giving credit where it's due, we love to see it. 🫢


This program is copyright 2001-2002 by Paul Warren.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

🚨 okay legal moment, pay attention: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

like literally no warranty, girl. don't come for him. πŸ’€πŸ™ˆ


🌈 SEE ALSO 🌈

  • RFC::RFC822::Address
  • Mail::Address

go read those too, they're the extended universe. 🧚


and that's the whole page, bestie β€” written for perl v5.36.0, dated 2022-10-13, under the name Address(3pm). now go validate some emails, you main character. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from