Sisimai::Address(3pm) | User Contributed Perl Documentation | Sisimai::Address(3pm) |
Sisimai::Address - Email address object
use Sisimai::Address; my $v = Sisimai::Address->new('neko@example.org'); print $v->user; # neko print $v->host; # example.org print $v->address; # neko@example.org
Sisimai::Address provide methods for dealing email address.
"new()" is a constructor of Sisimai::Address
my $v = Sisimai::Address->new('neko@example.org');
"find()" is a new parser for getting only email address from text including 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()" 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()" 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()" gets the original email address from alias
my $r = 'nyaa+neko@example.org'; print Sisimai::Address->expand_alias($r); # nyaa@example.org
"user()" returns a local part of the email address.
my $v = Sisimai::Address->new('neko@example.org'); print $v->user; # neko
"host()" returns a domain part of the email address.
my $v = Sisimai::Address->new('neko@example.org'); print $v->host; # example.org
"address()" returns an email address
my $v = Sisimai::Address->new('neko@example.org'); print $v->address; # neko@example.org
"verp()" returns a VERP email address
my $v = Sisimai::Address->new('neko+nyaan=example.org@example.org'); print $v->verp; # neko+nyaan=example.org@example.org print $v->address; # nyaan@example.org
"alias()" returns an email address (alias)
my $v = Sisimai::Address->new('neko+nyaan@example.org'); print $v->alias; # neko+nyaan@example.org print $v->address; # neko@example.org
"name()" returns a display name
my $e = '"Neko, Nyaan" <neko@example.org>'; my $r = Sisimai::Address->find($e); my $v = Sisimai::Address->make($r->[0]); print $v->address; # neko@example.org print $v->name; # Neko, Nyaan
"name()" returns a comment
my $e = '"Neko, Nyaan" <neko(nyaan)@example.org>'; my $v = Sisimai::Address->make(shift @{ Sisimai::Address->find($e) }); print $v->address; # neko@example.org print $v->comment; # nyaan
azumakuniyuki
Copyright (C) 2014-2021 azumakuniyuki, All rights reserved.
This software is distributed under The BSD 2-Clause License.
2022-12-23 | perl v5.36.0 |