Mail::M...uctured(3)
π Mail::Message::Field::Structured(3) π
User Contributed Perl Documentation
okay bestie, sit down, hydrate, because this one is a lot β it's literally one whole line of a structured message header, and it's giving quiet-legend energy. let's go π
β¨ NAME β¨
Mail::Message::Field::Structured β one line of a structured message header
πΈ INHERITANCE πΈ
Family tree check, because this class has royal lineage:
Mail::Message::Field::Structured
is a Mail::Message::Field::Full
is a Mail::Message::Field
is a Mail::Reporter
And it's the ancestor of some absolute main-character classes:
Mail::Message::Field::Structured is extended by
Mail::Message::Field::Addresses
Mail::Message::Field::AuthResults
Mail::Message::Field::DKIM
Mail::Message::Field::Date
Mail::Message::Field::URIs
π¦ SYNOPSIS π¦
my $f = Mail::Message::Field::Full
->new('Content-Type' => 'text/html');
my @encode = (charset => 'jp', use_continuations => 1);
$f->attribute('filename=passwd');
$f->attribute(filename => 'passwd', @encode);
my $attr = Mail::Message::Field::Attribute->new(...);
$f->attribute($attr);
π DESCRIPTION π
It extends the "DESCRIPTION" in Mail::Message::Field::Full, so if you want the full lore, that's where it lives. π
β OVERLOADED β
Extends the "OVERLOADED" in Mail::Message::Field::Full. Here's the whole overload lineup:
overload: "" stringificationβ Inherited, see "OVERLOADED" inMail::Message::Field::Fulloverload: '""' stringificationβ Inherited, see "OVERLOADED" inMail::Message::Fieldoverload: '0+' numificationβ Inherited, see "OVERLOADED" inMail::Message::Fieldoverload: '<='> numeric comparisonβ Inherited, see "OVERLOADED" inMail::Message::Fieldoverload: bool booleanβ Inherited, see "OVERLOADED" inMail::Message::Fieldoverload: cmp string comparisonβ Inherited, see "OVERLOADED" inMail::Message::Field
π METHODS π
Extends the "METHODS" in Mail::Message::Field::Full.
Constructors π§
Extends the "Constructors" in Mail::Message::Field::Full.
$obj->clone()β Inherited, see "Constructors" inMail::Message::Field$class->from($field, %options)β Inherited, see "Constructors" inMail::Message::Field::Full
$class->new(($line | $name, $body, @attributes), %options)
Two whole ways to birth this thing, pick your fighter:
new($line)β hand over a$lineexactly like you'd find it sitting in a file: a (possibly folded) line which is terminated by a new-line.new($name, $body, @attributes, %options)β a whole set of values that shape the line.
The $name is a wellformed header name (you may use wellformedName() if you wanna be sure about the casing). The $body is a string, one body object, or an ARRAY of body objects. When they're objects, they must fit the constructor of the field: the types that are accepted may differ. The @attributes LIST contains Mail::Message::Field::Attribute objects. And finally there are some %options. Improves base, see "METHODS" in Mail::Message::Field::Full.
-Option --Defined in --Default
attributes +[ ]
charset Mail::Message::Field::Full undef
datum undef
encoding Mail::Message::Field::Full 'q'
force Mail::Message::Field::Full false
language Mail::Message::Field::Full undef
attributes => \@attributes|\%attributesβ There are various ways to specify these attributes: pass anARRAYwhich list of key-value pairs representing@attributes, or anHASHcontaining these pairs, or anARRAYwithMail::Message::Field::Attributeobjects.charset => $charsetdatum => $dateβ okay so the method namebodyis very confusing, even in the RFC, like who approved that. In MailBox, for historical reasons,body()returns the part of the field contents before the first semi-colon.foldedBody()andunfoldedBody()address the whole field.
There is no common name for the piece of data before the parameters (attributes) in the field-content mentioned in the RFCs, so let's just call it "datum". π«Ά
encoding => 'q'|'Q'|'b'|'B'force => BOOLEANlanguage => $language
Β» example: of a structured field
my @attrs = (Mail::Message::Field::Attribute->new(...), ...);
my %options = (extra => 'the color blue');
my $t = Mail::Message::Field::Full->new(To => \@addrs, @attrs, %options);
Attributes π
Extends the "Attributes" in Mail::Message::Field::Full.
$obj->Name()β Inherited, see "Attributes" inMail::Message::Field$obj->body()β Inherited, see "Attributes" inMail::Message::Field$obj->folded()β Inherited, see "Attributes" inMail::Message::Field$obj->foldedBody( [$body] )β Inherited, see "Attributes" inMail::Message::Field$obj->name()β Inherited, see "Attributes" inMail::Message::Field$obj->unfoldedBody( [$body, [$wrap]] )β Inherited, see "Attributes" inMail::Message::Field$obj->wellformedName( [STRING] )β Inherited, see "Attributes" inMail::Message::Field
The field π¦
Extends the "The field" in Mail::Message::Field::Full.
$any->isStructured( [$name] )β Inherited, see "The field" inMail::Message::Field$obj->length()β Inherited, see "The field" inMail::Message::Field$obj->nrLines()β Inherited, see "The field" inMail::Message::Field$obj->print( [$fh] )β Inherited, see "The field" inMail::Message::Field$obj->size()β Inherited, see "The field" inMail::Message::Field$obj->string( [$wrap] )β Inherited, see "The field" inMail::Message::Field$obj->toDisclose()β Inherited, see "The field" inMail::Message::Field
Access to the body π
Extends the "Access to the body" in Mail::Message::Field::Full.
$obj->decodedBody(%options)β Inherited, see "Access to the body" inMail::Message::Field::Full
Access to the content π
Extends the "Access to the content" in Mail::Message::Field::Full.
$obj->addresses()β Inherited, see "Access to the content" inMail::Message::Field$obj->attrPairs()β Returns a list with attribute name and value pairs.$obj->attribute( $object|<STRING, %options>|<$name,$value,%options> )β Add an attribute to the field. The attributes are added left-to-right into the string representation of the field, although the order of the attributes is un-important, according to the RFCs.
You may pass a fully prepared Mail::Message::Field::Attribute $object, if you like to do all preparations for correct representation of the data yourself. You may also pass one STRING, which is a fully prepared attribute. This STRING will not be changed, so be careful about quoting and encodings.
As third possibility, you can specify an attribute $name and its $value. An attribute object will be created for you implicitly in both cases where such object is not supplied, passing the %options. See Mail::Message::Field::Attribute::new() about the available %options.
The attribute object is returned, however, when continuations are used this may be an object you already know about. undef is returned when construction fails (when the attribute is incorrect). Improves base, see "Access to the content" in Mail::Message::Field.
Β» example:
$f->attribute(filename => 'passwd');
$f->attribute(filename => 'passwd', use_continuations => 0);
my $attr = Mail::Message::Field::Attribute->new(...);
$f->attribute($attr);
$obj->attributes()β Returns a list with all attributes, which are allMail::Message::Field::Attributeobjects. The attributes are not ordered in any way. The list may be empty. Double attributes or continuations are folded into one. Improves base, see "Access to the content" inMail::Message::Field$obj->beautify()β Inherited, see "Access to the content" inMail::Message::Field::Full$obj->comment( [STRING] )β Inherited, see "Access to the content" inMail::Message::Field$any->createComment(STRING, %options)β Inherited, see "Access to the content" inMail::Message::Field::Full$any->createPhrase(STRING, %options)β Inherited, see "Access to the content" inMail::Message::Field::Full$any->dateToTimestamp(STRING)β Inherited, see "Access to the content" inMail::Message::Field$any->stripCFWS( [STRING] )β Inherited, see "Access to the content" inMail::Message::Field$obj->study()β Inherited, see "Access to the content" inMail::Message::Field$any->toDate( [$time] )β Inherited, see "Access to the content" inMail::Message::Field$obj->toInt()β Inherited, see "Access to the content" inMail::Message::Field
Internals π₯
Extends the "Internals" in Mail::Message::Field::Full.
$any->decode(STRING, %options)β Inherited, see "Internals" inMail::Message::Field::Full$obj->encode(STRING, %options)β Inherited, see "Internals" inMail::Message::Field::Full
Parsing π«
Extends the "Parsing" in Mail::Message::Field::Full.
$obj->consume( $line | <$name,<$body|$objects>> )β Inherited, see "Parsing" inMail::Message::Field$any->consumeComment(STRING)β Inherited, see "Parsing" inMail::Message::Field::Full$obj->consumeDotAtom(STRING)β Inherited, see "Parsing" inMail::Message::Field::Full$any->consumePhrase(STRING)β Inherited, see "Parsing" inMail::Message::Field::Full$obj->datum( [$value] )β The part of the field before the semi-colon (";").$obj->defaultWrapLength( [$length] )β Inherited, see "Parsing" inMail::Message::Field$any->fold( $name, $body, [$maxchars] )β Inherited, see "Parsing" inMail::Message::Field$obj->parse(STRING)β Inherited, see "Parsing" inMail::Message::Field::Full$obj->produceBody()β Inherited, see "Parsing" inMail::Message::Field::Full$obj->setWrapLength( [$length] )β Inherited, see "Parsing" inMail::Message::Field$obj->stringifyData(STRING|ARRAY|$objects)β Inherited, see "Parsing" inMail::Message::Field$obj->unfold(STRING)β Inherited, see "Parsing" inMail::Message::Field
Error handling π
Extends the "Error handling" in Mail::Message::Field::Full.
$obj->AUTOLOAD()β Inherited, see "Error handling" inMail::Reporter$obj->notImplemented()β Inherited, see "Error handling" inMail::Reporter
Cleanup π
Extends the "Cleanup" in Mail::Message::Field::Full.
$obj->DESTROY()β Inherited, see "Cleanup" inMail::Reporter
π DETAILS π
Extends the "DETAILS" in Mail::Message::Field::Full.
and bestie, hold on β there's more coming, part 2 is right there π
π₯ DIAGNOSTICS π₯
okay bestie, this is the part where the module yells at you. not in a mean way!! just so you know what went wrong. every single one of these is thrown/cast by a specific method, so you can trace it back. π
Error: class $package does not implement method $method.
FATAL, like actually fatal π β this specific $package (or one of its superclasses, which is giving "your whole family tree didn't teach you this") does not implement this method where it should. The tea here is: some other related classes do implement this method, but the class you're holding rn does not. So probably go investigate, and probably go tell the author of the package, fr fr. 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 are supposed to be numerical, bestie), but the data contains weird characters. it's giving chaos. Cast by toInt().
Error: field name too long (max $count), in '$name'.
The RFCs do not specify how long a field name can be β iconic of them, no cap β but at minimum it should be a few characters shorter than the line wrap. Cast by fold().
Warning: illegal character in charset '$name'.
The field is created with an utf8 string which only contains data from the specified character set. BUT that character set can never be a valid name because it contains characters that are not permitted. so like, structurally a no. Cast by encode().
Warning: illegal character in field name $name.
You're creating a new field that contains characters not permitted by the RFCs. Using this field in messages may break other e-mail clients or transfer agents, and therefore mutulate or extinguish your message πππ (yes, mutulate, that's what it says, we don't question the ancestors). Cast by consume().
Warning: illegal character in language '$name'.
The field is created with data specified to be in a certain language, however the name of that language cannot be valid: it contains characters not permitted by the RFCs. sad! 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().
π 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. slay π
and that's the whole page, bestie!! πΈ this doc lives in perl v5.42.0, and the page itself is dated 2026-02-05 β go forth and mail responsibly, mwah ππ¦π
π¦ 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