NAME
Sisimai::Address - Email address object
SYNOPSIS
use Sisimai::Address;
my $v = Sisimai::Address->new({ 'address' => 'neko@example.org' });
print $v->user; # neko
print $v->host; # example.org
print $v->address; # neko@example.org
print Sisimai::Address->is_emailaddress('neko@example.jp'); # 1
print Sisimai::Address->is_domainpart('example.jp'); # 1
print Sisimai::Address->is_mailerdaemon('neko@example.jp'); # 0
DESCRIPTION
Sisimai::Address
provide methods for dealing email address.
CLASS METHODS
is_emailaddress(email address)
is_emailaddress()
method checks the argument is valid email address or not.
print Sisimai::Address->is_emailaddress('neko@example.jp'); # 1
print Sisimai::Address->is_emailaddress('neko%example.jp'); # 0
my $addr_with_name = [
'Stray cat <neko@example.jp',
'=?UTF-8?B?55m954yr?= <shironeko@example.co.jp>',
];
for my $e ( @$addr_with_name ) {
print Sisimai::Address->is_emailaddress($e); # 1
}
is_mailerdaemon(email address)
is_mailerdaemon()
method checks the argument is mailer-daemon or not.
print Sisimai::Address->is_mailerdaemon('neko@example.jp'); # 0
print Sisimai::Address->is_mailerdaemon('mailer-daemon@example.jp'); # 1
find(String)
find()
method is a new parser for getting only the email address from the given string including an email addresses.
my $r = 'Stray cat <cat@example.org>, nyaa@example.org (White Cat)',
my $v = Sisimai::Address->find($r);
warn Dumper $v;
$VAR1 = [
{
'name' => 'Stray cat',
'address' => 'cat@example.org',
'comment' => ''
},
{
'name' => '',
'address' => 'nyaa@example.jp',
'comment' => '(White Cat)'
}
];
s3s4(email address)
s3s4()
method works Ruleset 3, and 4 of sendmail.cf.
my $r = [
'Stray cat <cat@example.org>',
'nyaa@example.org (White Cat)',
];
for my $e ( @$r ) {
print Sisimai::Address->s3s4($e); # cat@example.org
# nyaa@example.org
}
expand_verp(email address)
expand_verp()
method gets the original email address from VERP
my $r = 'nyaa+neko=example.org@example.org';
print Sisimai::Address->expand_verp($r); # neko@example.org
expand_alias(email address)
expand_alias()
method gets the original email address from the alias address
my $r = 'nyaa+neko@example.org';
print Sisimai::Address->expand_alias($r); # nyaa@example.org
INSTANCE METHODS
user()
user()
method returns a local part of the email address.
my $v = Sisimai::Address->new({ 'address' => 'neko@example.org' });
print $v->user; # neko
host()
host()
method returns a domain part of the email address.
my $v = Sisimai::Address->new({ 'address' => 'neko@example.org' });
print $v->host; # example.org
address()
address()
method returns an email address
my $v = Sisimai::Address->new({ 'address' => 'neko@example.org' });
print $v->address; # neko@example.org
verp()
verp()
method returns a VERP email address
my $v = Sisimai::Address->new({ 'address' => 'neko+nyaan=example.org@example.org' });
print $v->verp; # neko+nyaan=example.org@example.org
print $v->address; # nyaan@example.org
alias()
alias()
method returns an email address (alias)
my $v = Sisimai::Address->new({ 'address' => 'neko+nyaan@example.org' });
print $v->alias; # neko+nyaan@example.org
print $v->address; # neko@example.org
name()
name()
method returns a display name
my $e = '"Neko, Nyaan" <neko@example.org>';
my $r = Sisimai::Address->find($e);
my $v = Sisimai::Address->new($r->[0]);
print $v->address; # neko@example.org
print $v->name; # Neko, Nyaan
comment()
comment()
method returns a comment
my $e = '"Neko, Nyaan" <neko(nyaan)@example.org>';
my $v = Sisimai::Address->new(shift Sisimai::Address->find($e)->@*);
print $v->address; # neko@example.org
print $v->comment; # nyaan
AUTHOR
azumakuniyuki
COPYRIGHT
Copyright (C) 2014-2024 azumakuniyuki, All rights reserved.
LICENSE
This software is distributed under The BSD 2-Clause License.