PR

Mail::CheckUser -有効なメールアドレスかどうかをチェックする

Mail::CheckUser -有効なメールアドレスかどうかをチェックする(CASEY日本語訳)

スポンサードリンク

NAME

Mail::CheckUser – check email addresses for validity
Mail::CheckUser -有効なメールアドレスかどうかをチェックする

SYNOPSIS

use Mail::CheckUser qw(check_email);

my $ok = check_email($email_addr);

use Mail::CheckUser qw(:constants check_email last_check)

my $ok = check_email($email_addr);

print “DNS timeout\n”

if last_check()->{code} == CU_DNS_TIMEOUT;

use Mail::CheckUser;

my $res = Mail::CheckUser::check_email($email_addr);

DESCRIPTION

This Perl module provides routines for checking validity of email address.
このPerlモジュールはEメールアドレスの有効性をチェックするためのルーチンを提供します。

It makes several checks:
以下のチェックをします:

  1. It checks the syntax of an email address.
    メールアドレスの構文チェック
  2. It checks if there any “MX records” or “A records” for the domain part of the email address.
    メールアドレスのドメイン部分がMXレコードかAレコードかのチェック
  3. It tries to connect to an email server directly via SMTP to check if mailbox is valid. Old versions of this module performed this check via the VRFY command. Now the module uses another check; it uses a combination of MAIL and RCPT commands which simulates sending an email. It can detect bad mailboxes in many cases.
    メールボックスが有効であるかどうかチェックするために直接SMTPを通してメールサーバに接続しようとします。 このモジュールの古いバージョンはVRFYコマンドでこのチェックを実行しました。 今、モジュールは別のチェックを使用します; それは発信をシミュレートするメールとRCPTコマンドの組み合わせを使用します。 多くの場合、それは悪いメールボックスを検出することができます。

If is possible to turn off some or all networking checks (items 2 and 3). See “GLOBAL VARIABLES”.
いくつか興味を失うのにおいて可能であるか、またはチェック(項目2と3)をすべてネットワークでつなぐこと。 「グローバル変数」を見てください。

This module was designed with CGIs (or any other dynamic Web content programmed with Perl) in mind. Usually it is required to quickly check e-mail addresses in forms. If the check can’t be finished in reasonable time, the e-mail address should be treated as valid. This is the default policy. By default if a timeout happens the result of the check is treated as positive. This behavior can be overridden – see “GLOBAL VARIABLES”.
このモジュールはCGI(または、Perlでプログラムされたいかなる他のダイナミックなウェブ内容も)で念頭に設計されました。通常、すぐにフォームのEメールアドレスをチェックするのに必要です。チェックが妥当な時間で終わることができないなら、Eメールアドレスは有効であるとして扱われるべきです。 これはデフォルトです。 デフォルトで、タイムアウトが起こるなら、チェックの結果は積極的であるとして扱われます。この振舞いをくつがえすことができます– 「グローバル変数」を見てください。

IMPORTANT WARNING

In many cases there is no way to detect the validity of email addresses with network checks. For example, non-monolithic mail servers (such as Postfix and qmail) often report that a user exists even if it is not so. This is because in cases where the work of the server is split among many components, the SMTP server may not know how to check for the existence of a particular user. Systems like these will reject mail to unknown users, but they do so after the SMTP conversation. In cases like these, the only absolutely sure way to determine whether or not a user exists is to actually send a mail and wait to see if a bounce messages comes back. Obviously, this is not a workable strategy for this module. Does it mean that the network checks in this module are useless? No. For one thing, just the DNS checks go a long way towards weeding out mistyped domain parts. Also, there are still many SMTP servers that will reject a bad address during the SMTP conversation. Because of this, it’s still a useful part of checking for a valid email address. And this module was designed such that if there is exists possibility (however small) that the email address is valid, it will be treated as valid by this module.
多くの場合、ネットワークチェックがあるEメールアドレスの正当性を検出する方法が全くありません。例えば、したがって、それが報告しないでも、非一枚岩的なメールサーバ(Postfixやqmailなどの)は、しばしばユーザが存在すると報告します。 これはサーバの仕事が多くのコンポーネントの中で分けられる場合では、SMTPサーバが特定のユーザの存在がないかどうかチェックする方法を知らないかもしれないからです。 これらのようなシステムは未知のユーザにメールを拒絶するでしょうが、彼らはSMTPの会話の後にそうします。 これらのような場合では、ユーザが存在するかどうかが、弾みのメッセージであるなら実際にメールを送って、見るのを待つことになっているのを決定する唯一の絶対に確かな方法に戻ります。明らかに、これはこのモジュールのための実行可能な戦略ではありません。 それは、このモジュールにおけるネットワークチェックが役に立たないのを意味しますか? いいえ 一つには、まさしくDNSチェックはmistypedドメインの部品を取り外すことに向かってはるばる行きます。 また、まだ、SMTPの会話の間に悪いアドレスを拒絶する多くのSMTPプロトコルのサーバがあります。 これのために、それでも、それは有効なEメールアドレスがないかどうかチェックする役に立つ部分です。そして、このモジュールはEメールアドレスが可能性(どんなに小さくても)ですが、あれば存在する設計されたそのようなもの有効です、それがこのモジュールによって有効であるとして扱われるということでした。

Another warning is about $Mail::CheckUser::Treat_Timeout_As_Fail global variable. Use it carefully – if it is set to true then some valid email addresses can be treated as bad simply because an SMTP or DNS server responds slowly.
別の警告は$Mail::CheckUser::Treat_Timeout_As_Fail global variable.に関するものです。慎重にそれを使用してください–それが本当に設定されるなら、単にSMTPかDNSサーバがゆっくり反応するので、悪いとしていくつかの有効なEメールアドレスを扱うことができます。

Another warning is about $Mail::CheckUser::Treat_Full_As_Fail global variable. Use it carefully – if it is set to true then some valid email addresses can be treated as bad simply because their mailbox happens to be temporarily full.
別の警告は$Mail::CheckUser::Treat_Full_As_Fail global variable.に関するものです。グローバル変数として_Full_を扱ってください。 慎重にそれを使用してください–それが本当に設定されるなら、単にそれらのメールボックスがたまたま一時完全であるので、悪いとしていくつかの有効なEメールアドレスを扱うことができます。

EXAMPLE

This simple script checks if email address [email protected] is valid.
この簡単なスクリプトは、Eメールアドレス [email protected] が有効であるかどうかチェックします。

use Mail::CheckUser qw(check_email last_check);

my $email = ‘[email protected]’;

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”;

}

SUBROUTINES

$ok = check_email($email)

Validates email address $email. Return true if email address is valid and false otherwise.
Eメールアドレス$emailを有効にします。戻り値がTRUEなら存在し、そうでなければFALSEが返ります

$res = last_check()

Returns detailed result of last check made with check_email as hash reference:
最後の詳細なcheck_emailの結果がハッシュリファレンスとして返ります

<p class=”MsoNormal” style=”border-right: medium none; padding-right: 0mm; border-top: medium none; padding-left: 0mm; background: #eeeeee; padding-bottom: 0mm; border-left: medium none; padding-top: 0mm; border-bo

コメント

  1. firegoby より:

    PHPでメールアドレスを正確にチェックするクラス

    PerlのMail::CheckUserによく似た機能を提供するPHPクラスを作成しましたので公開します。
    このクラスを使用すると正規表現のみでチェックするよりも高い確率で無効なメールアドレスを検出…

  2. ホスト  より:

    参考になりました。

  3. admin より:

    お役に立ててよかったです。