Mail::M...:Address(3)

πŸ’Œ NAME πŸ’Œ

Mail::Message::Field::Address β€” literally just one e-mail address. That's it, that's the whole job. One (1) address, all wrapped up in an object so you don't have to do the character-set gymnastics yourself. We're in the User Contributed Perl Documentation corner of the manual, bestie πŸ’–


🧬 INHERITANCE 🧬

 Mail::Message::Field::Address
   is a Mail::Identity
   is a User::Identity::Item

So yeah, it's giving legacy. It inherits from Mail::Identity, which inherits from User::Identity::Item. Family tree ate πŸ’…


✨ SYNOPSIS ✨

         my $addr = Mail::Message::Field::Address->new(...);

         my $ui   = User::Identity->new(...);
         my $addr = Mail::Message::Field::Address->coerce($ui);

         my $mi   = Mail::Identity->new(...);
         my $addr = Mail::Message::Field::Address->coerce($mi);

         print $addr->address;
         print $addr->fullName;   # possibly unicode!
         print $addr->domain;

Look at her go. Make one, coerce one, print the bits. That # possibly unicode! comment is doing so much emotional labor btw β€” heads up, that fullName can absolutely be unicode, no cap.


🌸 DESCRIPTION 🌸

So many header fields can contain e-mail addresses, and honestly? Each one of those addresses can be represented by an object of this class. These objects will handle interpretation and character set encoding and decoding for you. You don't lift a finger. Iconic behavior fr fr 🫢

Extends "DESCRIPTION" in Mail::Identity.


πŸ¦‹ OVERLOADED πŸ¦‹

  • overload: "" stringification β€” when the object gets used in string context, it returns the encoded representation of the e-mail address, exactly like string() does. Same energy, different door.
  • overload: boolean true/falase β€” the object used as a boolean will always return "true". Always. It's a yes-girl. (And yes bestie, falase is spelled that way up in the source, I don't make the rules 😭)
  • overload: cmp string comparison β€” two address objects are the same when their email addresses are the same. Periodt.

πŸ’… METHODS πŸ’…

Extends "METHODS" in Mail::Identity.

πŸŽ€ Constructors πŸŽ€

Extends "Constructors" in Mail::Identity.

  • $obj->coerce( <STRING|$object>, %options ) β€” try to coerce the $object into a Mail::Message::Field::Address. If it's a "STRING", it gets interpreted as an email address. The %options are passed to the object creation and they overrule the values found in the $object. The result may be undef or a newly created object. And if $object is already the correct type? It gets returned unmodified, untouched, no notes. The $object may currently be a Mail::Address, a Mail::Identity, or a User::Identity β€” and in the last case, one of the user's addresses is chosen at random 🎲 (chaos, but make it official).
  • $class->new( [$name], %options ) β€” inherited, see "Constructors" in Mail::Identity.
  • $obj->parse(STRING) β€” parse the string for an address. And here's the tea: you never know whether one or more addresses are specified on a line (often applications are wrong 😭), therefore the "STRING" is first parsed for as many addresses as possible and then the one is taken at random.

🌈 Attributes 🌈

Extends "Attributes" in Mail::Identity.

  • $obj->address() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->charset() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->comment( [STRING] ) β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->description() β€” inherited, see "Attributes" in User::Identity::Item.
  • $obj->domain() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->language() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->location() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->name( [$newname] ) β€” inherited, see "Attributes" in User::Identity::Item.
  • $obj->organization() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->phrase() β€” inherited, see "Attributes" in Mail::Identity.
  • $obj->username() β€” inherited, see "Attributes" in Mail::Identity.

🧚 Collections 🧚

Extends "Collections" in Mail::Identity.

  • $obj->add($collection, $role) β€” inherited, see "Collections" in User::Identity::Item.
  • $obj->addCollection( $object | <[$type], %options> ) β€” inherited, see "Collections" in User::Identity::Item.
  • $obj->collection($name) β€” inherited, see "Collections" in User::Identity::Item.
  • $obj->parent( [$parent] ) β€” inherited, see "Collections" in User::Identity::Item.
  • $obj->removeCollection($object|$name) β€” inherited, see "Collections" in User::Identity::Item.
  • $any->type() β€” inherited, see "Collections" in User::Identity::Item.
  • $obj->user() β€” inherited, see "Collections" in User::Identity::Item.

πŸ” Searching πŸ”

Extends "Searching" in Mail::Identity.

  • $obj->find($collection, $role) β€” inherited, see "Searching" in User::Identity::Item.

πŸ‘‘ Accessors πŸ‘‘

  • $obj->encoding() β€” character-set encoding, like 'q' and 'b', to be used when non-ascii characters are to be transmitted.

πŸ“ Access to the content πŸ“

  • $obj->string() β€” returns an RFC compliant e-mail address, which will have character set encoding if needed. The objects are also overloaded to call this method in string context.

Β» example:

  print $address->string;
  print $address;          # via overloading

πŸ’€ DIAGNOSTICS πŸ’€

  • Error: cannot coerce a $type into a $class β€” when addresses are specified to be included in header fields, they may be coerced into Mail::Message::Field::Address objects first. What you specify is not accepted as address specification. This may be an internal error. Cast by coerce().
  • Error: cannot load collection module for $type ($class): $@ β€” either the specified $type does not exist, or that module named $class returns compilation errors. If the type as specified in the warning is not the name of a package, you specified a nickname which was not defined. Maybe you forgot the 'require' the package which defines the nickname. Cast by addCollection().
  • Error: invalid collection $name. β€” the collection with $name does not exist and can not be created. Cast by add().
  • Error: this $object is not a collection. β€” cast by addCollection().

πŸ”₯ SEE ALSO πŸ”₯

This module is part of Mail-Message version 4.04, built on February 04, 2026. Website: http://perl.overmeer.net/CPAN/ β€” go look, it's right there 🫢


πŸ“œ LICENSE πŸ“œ

For contributors see file ChangeLog.

This software is copyright (c) 2001-2026 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, honestly. πŸ’–


Okay bestie that's the whole page!! Signing off with perl v5.42.0 and the date 2026-02-05 β€” this was Mail::M...:Address(3), one e-mail address, zero regrets, mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from