Sisimai::RFC5322(3pm) | User Contributed Perl Documentation | Sisimai::RFC5322(3pm) |
Sisimai::RFC5322 - Email address related utilities
use Sisimai::RFC5322; print Sisimai::RFC5322->is_emailaddress('neko@example.jp'); # 1 print Sisimai::RFC5322->is_domainpart('example.jp'); # 1 print Sisimai::RFC5322->is_mailerdaemon('neko@example.jp'); # 0
Sisimai::RFC5322 provide methods for checking email address.
"is_emailaddress()" checks the argument is valid email address or not.
print Sisimai::RFC5322->is_emailaddress('neko@example.jp'); # 1 print Sisimai::RFC5322->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::RFC5322->is_emailaddress($e); # 1 }
"is_domainpart()" checks the argument is valid domain part of an email address or not.
print Sisimai::RFC5322->is_domainpart('neko@example.jp'); # 0 print Sisimai::RFC5322->is_domainpart('neko.example.jp'); # 1
"is_mailerdaemon()" checks the argument is mailer-daemon or not.
print Sisimai::RFC5322->is_mailerdaemon('neko@example.jp'); # 0 print Sisimai::RFC5322->is_mailerdaemon('mailer-daemon@example.jp'); # 1
"received()" returns array reference which include host names in the Received header.
my $v = 'from mx.example.org (c1.example.net [192.0.2.1]) by mx.example.jp'; my $r = Sisimai::RFC5322->received($v); warn Dumper $r; $VAR1 = [ 'mx.example.org', 'mx.example.jp' ];
"weedout()" returns string including only necessary fields from message/rfc822 part. This method is called from only Sisimai::Bite::Email::* modules.
my $v = <<'EOM'; From: postmaster@nyaan.example.org To: kijitora@example.jp Subject: Delivery failure X-Mailer: Neko mailer v2.22 EOM my $r = Sisimai::RFC5322->weedout([split("\n", $v)]); print $$r; From: postmaster@nyaan.example.org To: kijitora@example.jp Subject: Delivery failure
azumakuniyuki
Copyright (C) 2014-2018 azumakuniyuki, All rights reserved.
This software is distributed under The BSD 2-Clause License.
2018-11-15 | perl v5.28.0 |