Mail::M...ddresses(3)

✨ NAME ✨

okay so bestie, meet Mail::Message::Field::Addresses πŸ’Œ β€” it's literally the module for fields with e-mail addresses. That's the whole assignment. No cap.


🧬 INHERITANCE 🧬

the family tree, and yes it's giving royal lineage πŸ‘‘

Mail::Message::Field::Addresses
  is a Mail::Message::Field::Structured
  is a Mail::Message::Field::Full
  is a Mail::Message::Field
  is a Mail::Reporter

πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe check, copy-paste ready:

my $cc = Mail::Message::Field::Full->new('Cc');
my $me = Mail::Message::Field::Address->parse('"Test" <test@mail.box>')
my $other = Mail::Message::Field::Address->new(phrase => 'Other',
      address => 'other@example.com');

$cc->addAddress($me);
$cc->addAddress($other, group => 'them');
$cc->addAddress(phrase => 'third', address => 'more@any.museum',
  group => 'them');

my $group = $cc->addGroup(name => 'collegues');
$group->addAddress($me);
$group->addAddress(phrase => "You", address => 'you@example.com');

my $msg = Mail::Message->build(Cc => $cc);
print $msg->string;

my $g  = Mail::Message::Field::AddrGroup->new(...);
$cc->addGroup($g);

πŸ’… DESCRIPTION πŸ’…

so, this class handles all the header fields that contain nothing but e-mail addresses. Not every address field plays by the same rules, bestie, but here's the tea: they all get parsed the same way anyway. Why? Because you literally never know how broken the apps are that made those messages 😭. Trust.

and when you try to build stuff that a certain kind of field isn't allowed to have? You get warned. Not ignored, not silently yeeted β€” warned. πŸ™ˆ

fun history lesson: RFC5322 said address groups were fine for "To" and "Cc", but not allowed in "From" and "Sender" fields (amongst others). That whole restriction got lifted by RFC6854 in 2013, periodt. πŸ‘‘ <https://www.rfc-editor.org/rfc/rfc6854>

it extends "DESCRIPTION" in Mail::Message::Field::Structured. 🫢


🌈 OVERLOADED 🌈

extends "OVERLOADED" in Mail::Message::Field::Structured.

  • overload: "" stringification β€” inherited, see "OVERLOADED" in Mail::Message::Field::Full
  • overload: '""' stringification β€” inherited, see "OVERLOADED" in Mail::Message::Field
  • overload: '0+' numification β€” inherited, see "OVERLOADED" in Mail::Message::Field
  • overload: '<=' numeric comparison β€” inherited, see "OVERLOADED" in Mail::Message::Field
  • overload: bool boolean β€” inherited, see "OVERLOADED" in Mail::Message::Field
  • overload: cmp string comparison β€” inherited, see "OVERLOADED" in Mail::Message::Field

πŸ”₯ METHODS πŸ”₯

extends "METHODS" in Mail::Message::Field::Structured.

🌸 Constructors 🌸

extends "Constructors" in Mail::Message::Field::Structured.

  • $obj->clone() β€” inherited, see "Constructors" in Mail::Message::Field
  • $class->from($field, %options) β€” inherited, see "Constructors" in Mail::Message::Field::Full
  • $class->new() β€” inherited, see "METHODS" in Mail::Message::Field::Structured

and here are the options it takes, bestie β€” look at the defaults, they're iconic:

 -Option    --Defined in                      --Default
  attributes  Mail::Message::Field::Structured  <ignored>
  charset     Mail::Message::Field::Full        undef
  datum       Mail::Message::Field::Structured  undef
  encoding    Mail::Message::Field::Full        'q'
  force       Mail::Message::Field::Full        false
  language    Mail::Message::Field::Full        undef
  • attributes => \@attributes|\%attributes
  • charset => $charset
  • datum => $date
  • encoding => 'q'|'Q'|'b'|'B'
  • force => BOOLEAN
  • language => $language

πŸ¦‹ Attributes πŸ¦‹

extends "Attributes" in Mail::Message::Field::Structured.

  • $obj->Name() β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->body() β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->folded() β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->foldedBody( [$body] ) β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->name() β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->unfoldedBody( [$body, [$wrap]] ) β€” inherited, see "Attributes" in Mail::Message::Field
  • $obj->wellformedName( [STRING] ) β€” inherited, see "Attributes" in Mail::Message::Field

πŸŽ€ The field πŸŽ€

extends "The field" in Mail::Message::Field::Structured.

  • $any->isStructured( [$name] ) β€” inherited, see "The field" in Mail::Message::Field
  • $obj->length() β€” inherited, see "The field" in Mail::Message::Field
  • $obj->nrLines() β€” inherited, see "The field" in Mail::Message::Field
  • $obj->print( [$fh] ) β€” inherited, see "The field" in Mail::Message::Field
  • $obj->size() β€” inherited, see "The field" in Mail::Message::Field
  • $obj->string( [$wrap] ) β€” inherited, see "The field" in Mail::Message::Field
  • $obj->toDisclose() β€” inherited, see "The field" in Mail::Message::Field

πŸ’– Access to the body πŸ’–

extends "Access to the body" in Mail::Message::Field::Structured.

  • $obj->decodedBody(%options) β€” inherited, see "Access to the body" in Mail::Message::Field::Full

✨ Access to the content ✨

extends "Access to the content" in Mail::Message::Field::Structured.

  • $obj->addAddress( [$address], %options ) β€” adds an $address to the field. The addresses are organized into groups, bestie. If you don't name a group, the default group gets the address. And if you don't even pass an $address, the options alone have to be enough to build a Mail::Message::Field::Address from it β€” so go check the %options of Mail::Message::Field::Address::new(). Here's the one option it cares about:
 -Option--Default
  group   ''
  • group => STRING
  • $obj->addAttribute(...) β€” nope, not today. Attributes are not supported for address fields. πŸ’€
  • $obj->addGroup($group|%options) β€” adds a whole group of addresses to this field. You can hand it a $group, which is a Mail::Message::Field::AddrGroup object, or it'll make one for you from the %options. Either way it hands the group back to you. 🫢
 -Option--Default
  name    ''
  • name => STRING
  • $obj->addresses() β€” returns a list of every address defined in any group of addresses β€” i.e. every address written on the line. They come back as Mail::Message::Field::Address objects. It improves on the base, see "Access to the content" in Mail::Message::Field.

Β» example:

  my @addr = $field->addresses;
  • $obj->attrPairs() β€” inherited, see "Access to the content" in Mail::Message::Field::Structured
  • $obj->attribute( $object|<STRING, %options>|<$name,$value,%options> ) β€” inherited, see "Access to the content" in Mail::Message::Field::Structured
  • $obj->attributes() β€” inherited, see "Access to the content" in Mail::Message::Field::Structured
  • $obj->beautify() β€” inherited, see "Access to the content" in Mail::Message::Field::Full
  • $obj->comment( [STRING] ) β€” inherited, see "Access to the content" in Mail::Message::Field
  • $any->createComment(STRING, %options) β€” inherited, see "Access to the content" in Mail::Message::Field::Full
  • $any->createPhrase(STRING, %options) β€” inherited, see "Access to the content" in Mail::Message::Field::Full
  • $any->dateToTimestamp(STRING) β€” inherited, see "Access to the content" in Mail::Message::Field
  • $obj->group($name) β€” gives you back the group of addresses named $name, or undef if that group isn't a thing. And if $name is undef? Then you get the default groep back. (yes that's how the original spells it, we keep it πŸ’…)
  • $obj->groupNames() β€” returns a list of all the group names that are defined.
  • $obj->groups() β€” returns every address group defined in this field. Each element is a Mail::Message::Field::AddrGroup object. slay.
  • $any->stripCFWS( [STRING] ) β€” inherited, see "Access to the content" in Mail::Message::Field
  • $obj->study() β€” inherited, see "Access to the content" in Mail::Message::Field
  • $any->toDate( [$time] ) β€” inherited, see "Access to the content" in Mail::Message::Field
  • $obj->toInt() β€” inherited, see "Access to the content" in Mail::Message::Field

🧚 Internals 🧚

extends "Internals" in Mail::Message::Field::Structured.

  • $any->decode(STRING, %options) β€” inherited, see "Internals" in Mail::Message::Field::Full
  • $obj->encode(STRING, %options) β€” inherited, see "Internals" in Mail::Message::Field::Full

πŸ“ Parsing πŸ“

extends "Parsing" in Mail::Message::Field::Structured.

  • $obj->consume( $line | <$name,<$body|$objects>> ) β€” inherited, see "Parsing" in Mail::Message::Field
  • $obj->consumeAddress(STRING, %options) β€” tries to distill address info out of the "STRING". You get back an address object and the leftover string. And if no address was found? The first value returned is undef. 😭
  • $any->consumeComment(STRING) β€” inherited, see "Parsing" in Mail::Message::Field::Full
  • $obj->consumeDomain(STRING) β€” tries to pull a valid domain representation out of "STRING". You get back the domain string as found (or undef) plus the rest of the string.
  • $obj->consumeDotAtom(STRING) β€” inherited, see "Parsing" in Mail::Message::Field::Full
  • $any->consumePhrase(STRING) β€” inherited, see "Parsing" in Mail::Message::Field::Full
  • $obj->datum( [$value] ) β€” inherited, see "Parsing" in Mail::Message::Field::Structured
  • $obj->defaultWrapLength( [$length] ) β€” inherited, see "Parsing" in Mail::Message::Field
  • $any->fold( $name, $body, [$maxchars] ) β€” inherited, see "Parsing" in Mail::Message::Field
  • $obj->parse($string) β€” inherited, see "Parsing" in Mail::Message::Field::Full
  • $obj->produceBody() β€” inherited, see "Parsing" in Mail::Message::Field::Full
  • $obj->setWrapLength( [$length] ) β€” inherited, see "Parsing" in Mail::Message::Field
  • $obj->stringifyData(STRING|ARRAY|$objects) β€” inherited, see "Parsing" in Mail::Message::Field
  • $obj->unfold(STRING) β€” inherited, see "Parsing" in Mail::Message::Field

πŸ’œ Error handling πŸ’œ

extends "Error handling" in Mail::Message::Field::Structured.

  • $obj->AUTOLOAD() β€” inherited, see "Error handling" in Mail::Reporter
  • $obj->notImplemented() β€” inherited, see "Error handling" in Mail::Reporter

⭐ Cleanup ⭐

extends "Cleanup" in Mail::Message::Field::Structured.

  • $obj->DESTROY() β€” inherited, see "Cleanup" in Mail::Reporter

🌟 DETAILS 🌟

extends "DETAILS" in Mail::Message::Field::Structured.


still with me? good, because there's more coming in part 2, bestie 🫢 don't go anywhere

πŸ’₯ DIAGNOSTICS πŸ’₯

okay bestie, this is the part where the module yells at you πŸ’€ every single one of these is something it can throw at your face, so let's go through them one by one, no skipping, no cap.

  • Error: class $package does not implement method $method.

Fatal error, bestie. The specific $package (or one of its superclasses) does not implement this method even though it lowkey should. What it means: some other related classes do implement it, but this one just… doesn't. Probably you should investigate that, and probably inform the author of the package. Cast by notImplemented().

  • Warning: field content is not numerical: $content

You asked for the numeric value of a field (like, the Lines or Content-Length fields should be numerical, that's the whole vibe), but the data contains weird characters instead. Cast by toInt().

  • Error: field name too long (max $count), in '$name'.

The RFCs never specified how long a field name can be β€” iconic of them, honestly β€” but at minimum it should be a few characters shorter than the line wrap. Cast by fold().

  • Warning: ignoring addressless phrase '$phrase'.

That's the whole message, bestie, no elaboration given. Cast by parse().

  • Warning: illegal character in charset '$name'.

The field is created with an utf8 string which only contains data from the specified character set. But plot twist: that character set can never be a valid name, because it contains characters that aren't permitted. Cast by encode().

  • Warning: illegal character in field name $name.

You're creating a new field that contains characters the RFCs don't permit. Using this field in messages may break other e-mail clients or transfer agents, and therefore mutulate or extinguish your message. 😭 so yeah, be careful. Cast by consume().

  • Warning: illegal character in language '$name'.

The field is created with data specified to be in a certain language, but the name of that language can't be valid β€” it contains characters the RFCs don't permit. Cast by encode().

  • Warning: illegal encoding '$name', using 'q'.

The RFCs only permit base64 ("b " or "B ") or quoted-printable ("q" or "Q") encoding. Anything other than these four options is illegal. Periodt. Cast by encode().

  • Warning: illegal part in address field $name: $part.

Cast by parse().

  • Error: no attributes for address fields.

It is not possible to add attributes to address fields β€” the RFCs simply don't permit it. Cast by addAttribute().


πŸ‘€ SEE ALSO πŸ‘€

This module is part of Mail-Message version 4.04, built on February 04, 2026. Website: http://perl.overmeer.net/CPAN/ πŸ¦‹


πŸ“œ 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. πŸ’–


and that's a wrap, bestie πŸŽ€ this whole thing came to you courtesy of perl v5.42.0, dated 2026-02-05, and it lives under the very iconic name Mail::M...ddresses(3) β€” go forth and send some flawless mail ✨🫢

πŸ“¦ where this page comes from