memo.xight.org

日々のメモ

メールアドレスが正しいかを判定するモジュール

Email::Valid

#!/usr/bin/perl
use Email::Valid;
print (Email::Valid->address('user@example.com') ? 'yes' : 'no');


Mail::CheckUser

#!/usr/bin/perl
use Mail::CheckUser qw(check_email last_check);

my $email = 'user@example.com';

if(check_email($email)) {
	print "E-mail address <$email> is OK\n";
} else {
	print "E-mail address <$email> isn't valid: ", last_check()->{reason}, "\n";
}


Data::Validate::Email

use Data::Validate::Email qw(is_email is_email_rfc822);

if(is_email($suspect)){
	print "Looks like an email address\n";
} elsif(is_email_rfc822($suspect)){
	print "Doesn't much look like an email address, but passes rfc822\n";
} else {
	print "Not an email address\n";
}


Reference

Email::Valid
Debian パッケージディレクトリ検索 (バイナリ) - libemail-valid-perl

Mail::CheckUser

Data::Validate::Email