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" 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 the "METHODS" in Mail::Message::Field::Full.

Constructors 🧚

Extends the "Constructors" in Mail::Message::Field::Full.

  • $obj->clone() β€” Inherited, see "Constructors" in Mail::Message::Field
  • $class->from($field, %options) β€” Inherited, see "Constructors" in Mail::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 $line exactly 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 an ARRAY which list of key-value pairs representing @attributes, or an HASH containing these pairs, or an ARRAY with Mail::Message::Field::Attribute objects.
  • charset => $charset
  • datum => $date β€” okay so the method name body is 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() and unfoldedBody() 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 => BOOLEAN
  • language => $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" 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 "The field" in Mail::Message::Field::Full.

  • $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 the "Access to the body" in Mail::Message::Field::Full.

  • $obj->decodedBody(%options) β€” Inherited, see "Access to the body" in Mail::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" in Mail::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 all Mail::Message::Field::Attribute objects. 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" in Mail::Message::Field
  • $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
  • $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 the "Internals" in Mail::Message::Field::Full.

  • $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 the "Parsing" in Mail::Message::Field::Full.

  • $obj->consume( $line | <$name,<$body|$objects>> ) β€” Inherited, see "Parsing" in Mail::Message::Field
  • $any->consumeComment(STRING) β€” Inherited, see "Parsing" in Mail::Message::Field::Full
  • $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] ) β€” The part of the field before the semi-colon (";").
  • $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 the "Error handling" in Mail::Message::Field::Full.

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

Cleanup πŸ™ˆ

Extends the "Cleanup" in Mail::Message::Field::Full.

  • $obj->DESTROY() β€” Inherited, see "Cleanup" in Mail::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