NAME

Sisimai::RFC5322 - Email address related utilities

SYNOPSIS

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

DESCRIPTION

Sisimai::RFC5322 provide methods for checking email address.

CLASS METHODS

is_emailaddress(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(Domain)

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_domainpart(Domain)

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(String)

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(Array)

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

AUTHOR

azumakuniyuki

COPYRIGHT

Copyright (C) 2014-2018 azumakuniyuki, All rights reserved.

LICENSE

This software is distributed under The BSD 2-Clause License.