Mail::Identity(3)
π¦ NAME π¦
Mail::Identity β an e-mail role
bestie, this is the User Contributed Perl Documentation page for it, and we are gonna go through every single line together π
π INHERITANCE π
Mail::Identity
is a User::Identity::Item
β¨ SYNOPSIS β¨
use User::Identity;
use Mail::Identity;
my $me = User::Identity->new(...);
my $addr = Mail::Identity->new(address => 'x@y');
$me->add(email => $addr);
# Simpler
use User::Identity;
my $me = User::Identity->new(...);
my $addr = $me->add(email => 'x@y');
my $addr = $me->add(email => 'home', address => 'x@y');
# Conversion
my $ma = Mail::Address->new(...);
my $mi = Mail::Identity->coerce($ma);
π«Ά DESCRIPTION π«Ά
The Mail::Identity object holds the description of a role played by a human when sending e-mail. Most people have more than one role these days β like, obviously β for instance a private role and a company role, each with different e-mail addresses. It's giving multitudes, and honestly? Slay.
A Mail::Identity object combines an e-mail address, a user description (the "phrase"), a signature, a pgp-key, and so on. All fields are optional, and some fields are smart. One such set of data represents one role. So Mail::Identity is the smart cousine of the Mail::Address object. Iconic behaviour, no cap.
Extends "DESCRIPTION" in User::Identity::Item.
π METHODS π
Extends "METHODS" in User::Identity::Item.
π Constructors π
Extends "Constructors" in User::Identity::Item.
$class->new( [$name], %options )
-Option --Defined in --Default
address <usernameP<@domain> or name>
charset <user's charset>
comment <user's fullname if phrase is different>
description User::Identity::Item undef
domain <from email or localhost>
language <from user>
location <random user's location>
name User::Identity::Item <phrase or user's fullName>
organization <location's organization>
parent User::Identity::Item undef
pgp_key undef
phrase <user's fullName>
signature undef
username <from address or user's nickname>
Okay so here's every single option, one by one, no skipping bestie π
address=> STRING β the e-mail address is constructed from the username/domain, but when both do not exist, thenameis taken. Default:<usernameP<@domain> or name>.charset=> STRING β default:<user's charset>.comment=> STRING β default:<user's fullname if phrase is different>.description=> STRING β defined inUser::Identity::Item, defaultundef.domain=> STRING β default:<from email or localhost>.language=> STRING β default:<from user>.location=> $name|OBJECT β the user's location which relates to this mail identity. This can be specified as location$name(which will be looked-up when needed), or as aUser::Identity::Locationobject. Default:<random user's location>.name=> STRING β defined inUser::Identity::Item, default<phrase or user's fullName>.organization=> STRING β usually defined for e-mail addresses which are used by a company or other organization, but less common for personal addresses. This value will be used to fill theOrganizationheader field of messages. Default:<location's organization>.parent=> OBJECT β defined inUser::Identity::Item, defaultundef.pgp_key=> STRING|FILENAME β defaultundef.phrase=> STRING β default:<user's fullName>.signature=> STRING β defaultundef.username=> STRING β default:<from address or user's nickname>.
πΈ Attributes πΈ
Extends "Attributes" in User::Identity::Item.
$obj->address()β returns the e-mail address for this role. If none was specified, it will be constructed from the username and domain. If those are not present as well, then thename()is used when it contains a"@", else the user's nickname is taken.$obj->charset()β returns the character set used incommentandphrase. When set to"undef", the strings (are already encoded to) contain only ASCII characters. This defaults to the value of the user's charset, if a user is defined.$obj->comment( [STRING] )β e-mail addresses, when included in message MIME headers, can contain a comment. The RFCs advice not to store useful information in these comments, but it you really want to, you can do it. The comment defaults to the user's fullname if the phrase is not the fullname and there is a user defined. Comments will be enclosed in parenthesis when used. Parenthesis (matching) or non-matching) which are already in the string will carefully escaped when needed. You do not need to worry. π§$obj->description()β inherited, see "Attributes" in User::Identity::Item.$obj->domain()β the domain is the part of the e-mail address after the"@"-sign. When this is not defined, it can be deducted from the email address (seeaddress()). If nothing is known,"localhost"is returned.$obj->language()β returns the language which is used for the description fields of this e-mail address, which defaults to the user's language.$obj->location()β returns the object which describes to which location this mail address relates. The location may be used to find the name of the organization involved, or to create a signature. If no location is specified, but a user is defined which has locations, one of those is randomly chosen. π²$obj->name( [$newname] )β inherited, see "Attributes" in User::Identity::Item.$obj->organization()β returns the organization which relates to this e-mail identity. If not explicitly specified, it is tried to be found via the location.$obj->phrase()β the phrase is used in an e-mail address to explain who is sending the message. This usually is the fullname (the user's fullname is used by default), description of your function (Webmaster), or any other text. When an email string is produced, the phase will be quoted if needed. Quotes which are within the string will automatically be escaped, so you do no need to worry: input cannot break the outcome! π₯$obj->username()β returns the username of this e-mail address. If none is specified, first it is tried to extract it from the specified e-mail address. If there is also no username in the e-mail address, the user identity's nickname is taken.
π Collections π
Extends "Collections" in User::Identity::Item.
$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 User::Identity::Item.
$obj->find($collection, $role)β inherited, see "Searching" in User::Identity::Item.
π DIAGNOSTICS π
Error: cannot load collection module for $type ($class): $@β either the specified$typedoes not exist, or that module named$classreturns 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 byaddCollection().Error: nvalid collection $name.β the collection with$namedoes not exist and can not be created. Cast byadd().Error: this $object is not a collection.β cast byaddCollection().
ngl that second one says nvalid and we are keeping it exactly as written, character for character. Not a typo of mine bestie, it's canon π
π SEE ALSO π
This module is part of User-Identity version 4.00, built on December 12, 2025. Website: http://perl.overmeer.net/CPAN/
π LICENSE π
For contributors see file ChangeLog.
This software is copyright (c) 2003-2025 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.
okay that's the whole page, you ate it, I'm so proud of you π₯Ή One last thing β this was perl v5.42.0, dated 2026-01-17, filed under Mail::Identity(3). Now go send some e-mail with main character energy β¨ππ
π¦ where this page comes from
- fedora 44: perl-User-Identity 4.00-2.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