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::Fulloverload: '""' stringificationβ inherited, see "OVERLOADED" in Mail::Message::Fieldoverload: '0+' numificationβ inherited, see "OVERLOADED" in Mail::Message::Fieldoverload: '<='numeric comparison β inherited, see "OVERLOADED" in Mail::Message::Fieldoverload: bool booleanβ inherited, see "OVERLOADED" in Mail::Message::Fieldoverload: 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|\%attributescharset => $charsetdatum => $dateencoding => 'q'|'Q'|'b'|'B'force => BOOLEANlanguage => $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$addressto 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 aMail::Message::Field::Addressfrom it β so go check the%optionsofMail::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 aMail::Message::Field::AddrGroupobject, 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 asMail::Message::Field::Addressobjects. 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, orundefif that group isn't a thing. And if$nameisundef? 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 aMail::Message::Field::AddrGroupobject. 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 isundef. π$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 (orundef) 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
- fedora 44: perl-Mail-Message 4.04-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms