=encoding euc-jp =head1 NAME Email::Valid - インターネット電子メールアドレスの正当性のチェック =head1 SYNOPSIS use Email::Valid; print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no'); =head1 DESCRIPTION =begin original This module determines whether an email address is well-formed, and optionally, whether a mail host exists for the domain. =end original このモジュールは、電子メールアドレスが適格であるか否かを判断します。 さらに、そのドメインのメールホストが存在するか否かも判断します。 =begin original Please note that there is no way to determine whether an address is deliverable without attempting delivery (for details, see perlfaq 9). =end original 実際に配送することなしに電子メールアドレスが配送可能か否かを 判断することはできないということに留意してください。 (詳細については、perlfaq 9 を見てください。) =head1 PREREQUISITES =begin original This module requires perl 5.004 or later and the Mail::Address module. Either the Net::DNS module or the nslookup utility is required for DNS checks. The Net::Domain::TLD module is required to check the validity of top level domains. =end original このモジュールは perl 5.004 以降と Mail::Address を要求します。 また、DNS チェックのために Net::DNS モジュールか nslookup ユーティリティのどちらかを要求します。Net::Domain::TLD モジュールは トップレベルドメインの妥当性チェックのために必要です。 =head1 METHODS =begin original Every method which accepts an
parameter may be passed either a string or an instance of the Mail::Address class. All errors raise an exception. =end original
パラメータを受け取るための全てのメソッドには、 文字列か Mail::Address クラスのインスタンスのどちらかを 渡すことができます。全てのエラーには例外が発生します。 =over 4 =item new ( [PARAMS] ) =begin original This method is used to construct an Email::Valid object. It accepts an optional list of named parameters to control the behavior of the object at instantiation. =end original このメソッドは、Email::Valid オブジェクトを生成します。 パラメータの名前のオプションのリストを渡すことによって オブジェクトの振る舞いを変更することができます。 =begin original The following named parameters are allowed. See the individual methods below of details. =end original 許可されているパラメータの名前は次のものです。 個々の詳細は下にある説明を見てください。 -mxcheck -tldcheck -fudge -fqdn -local_rules =item mx (
| ) =begin original This method accepts an email address or domain name and determines whether a DNS record (A or MX) exists for it. =end original このメソッドは、電子メールアドレスかドメイン名を渡すことによって、 (A か MX の)DNS レコードが存在するか否かを判断します。 =begin original The method returns true if a record is found and undef if not. =end original このメソッドはレコードが見つかったならば true を、そうでない ならば undef を返します。 =begin original Either the Net::DNS module or the nslookup utility is required for DNS checks. Using Net::DNS is the preferred method since error handling is improved. If Net::DNS is available, you can modify the behavior of the resolver (e.g. change the default tcp_timeout value) by manipulating the global Net::DNS::Resolver instance stored in $Email::Valid::Resolver. =end original DNS チェックには、Net::DNS モジュールか nslookup ユーティリティの どちらかが必要です。Net::DNS モジュールを用いた方が、良いエラー ハンドリングを得ることができます。もし、Net::DNS モジュールが 利用できるならば、あなたは $Email::Valid::Resolver に格納されている グローバルな Net::DNS::Resolver インスタンスの操作によって (例えば tcp_timeout の初期値を変更するなどの)レゾルバの振る舞いを 変更することができます。 =item rfc822 (
) =begin original This method determines whether an address conforms to the RFC822 specification (except for nested comments). It returns true if it conforms and undef if not. =end original このメソッドは、アドレスが RFC822 の仕様に従っているか否かを 判断します。但し、ネストしたコメントには対応していません。 仕様に従っているならば true を、そうでないならば undef を返します。 =item fudge ( | ) =begin original Specifies whether calls to address() should attempt to correct common addressing errors. Currently, this results in the removal of spaces in AOL addresses, and the conversion of commas to periods in Compuserve addresses. The default is false. =end original address() が呼ばれた際に、一般的なアドレスのエラーがあれば 修正しようと試みます。今のところは、AOL のアドレスの場合は、 空白文字を削除し、Compuserve アドレスの場合は、コンマをピリオドに 置換します。初期値は false です。 =item fqdn ( | ) =begin original Species whether addresses passed to address() must contain a fully qualified domain name (FQDN). The default is true. =end original address() にアドレスが渡されたときに正規の完全なドメイン名(FQDN)を 持つのかをチェックします。初期値は true です。 =item local_rules ( | ) =begin original Specifies whether addresses passed to address() should be tested for domain specific restrictions. Currently, this is limited to certain AOL restrictions that I'm aware of. The default is false. =end original address() にアドレスが渡されたときに特定の制約事項を持つドメインの アドレスをチェックします。今のところは AOL の制約事項の検出に 限定されています。初期値は false です。 =item mxcheck ( | ) =begin original Specifies whether addresses passed to address() should be checked for a valid DNS entry. The default is false. =end original address() にアドレスが渡されたときに正しい DNS エントリーで あるのかをチェックします。初期値は false です。 =item tldcheck ( | ) =begin original Specifies whether addresses passed to address() should be checked for a valid top level domains. The default is false. =end original address() にアドレスが渡されたときに正しいトップレベルドメインで あるのかをチェックします。初期値は false です。 =item address (
) =begin original This is the primary method which determines whether an email address is valid. It's behavior is modified by the values of mxcheck(), tldcheck(), local_rules(), fqdn(), and fudge(). If the address passes all checks, the (possibly modified) address is returned as a string. Otherwise, the undefined value is returned. In a list context, the method also returns an instance of the Mail::Address class representing the email address. =end original 電子メールアドレスが正当である(valid)か否かを判断するための 主要な(primary)メソッドです。mxcheck() や tldcheck()、local_rules()、 fqdn()、fudge() の値によって振る舞いを変更できます。もし、 アドレスが全てのチェックで問題がなかったならば、 (場合によっては修正された)アドレスを文字列として返します。 そうでなければ、未定義値を返します。リストコンテキストならば、 電子メールアドレスを表現するクラスである Mail::Address の インスタンスも返します。 =item details () =begin original If the last call to address() returned undef, you can call this method to determine why it failed. Possible values are: =end original 最後に呼ばれた address() が undef を返したときに、 どのチェック項目で失敗したのかを返します。 次の値が用意されています。 rfc822 local_rules fqdn mxcheck tldcheck =begin original If the class is not instantiated, you can get the same information from the global $Email::Valid::Details. =end original もし、クラスのインスタンスを生成していないならば、グローバル変数 $Email::Valid::Details から同様の情報を得ることができます。 =back =head1 EXAMPLES =begin original Let's see if the address 'maurice@hevanet.com' conforms to the RFC822 specification: =end original それでは、RFC822 の仕様に従っている 'maurice@hevanet.com' という アドレスでの例を見てみましょう。 print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no'); =begin original Additionally, let's make sure there's a mail host for it: =end original 更に、メールホストを確認してみましょう。 print (Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ) ? 'yes' : 'no'); =begin original Let's see an example of how the address may be modified: =end original アドレスを修正する場合の例を見てみましょう。 $addr = Email::Valid->address('Alfred Neuman '); print "$addr\n"; # prints Neuman@foo.bar =begin original Now let's add the check for top level domains: =end original トップレベルドメインのチェックを追加してみましょう。 $addr = Email::Valid->address( -address => 'Neuman@foo.bar', -tldcheck => 1 ); print "$addr\n"; # doesn't print anything =begin original Need to determine why an address failed? =end original 何故アドレスが正しくないのかの理由が必要な場合は次のようになります。 unless(Email::Valid->address('maurice@hevanet')) { print "address failed $Email::Valid::Details check.\n"; } =begin original If an error is encountered, an exception is raised. This is really only possible when performing DNS queries. Trap any exceptions by wrapping the call in an eval block: =end original エラーがあった場合に例外を発生させます。これは、DNS クエリを実行 したときだけ使えます。eval ブロックで括ることによって、 例外を捕捉します。 eval { $addr = Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ); }; warn "an error was encountered: $@" if $@; =head1 BUGS =begin original Email::Valid should work with Perl for Win32. In my experience, however, Net::DNS queries seem to take an extremely long time when a record cannot be found. =end original Email::Valid は Perl for Win32 で動作します。しかし、私の経験では、 Net::DNS クエリを使ったとしても、レコードを見つけることが できなかった際に極めて長い時間待たされるように思います。 =head1 AUTHOR Copyright 1998-2003, Maurice Aubrey Emaurice@hevanet.comE. All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself. =head1 CREDITS =begin original Significant portions of this module are based on the ckaddr program written by Tom Christiansen and the RFC822 address pattern developed by Jeffrey Friedl. Neither were involved in the construction of this module; all errors are mine. =end original このモジュールの大部分は、Tom Christiansen によって書かれた ckaddr プログラムと Jeffrey Friedl によって書かれた RFC822 アドレスの正規表現 をベースにしています。 どちらもこのモジュールの構築には関係ありません。 全ての誤りは私自身に責任があります。 =begin original Thanks very much to the following people for their suggestions and bug fixes: =end original 下に挙げる人々の示唆やバグ修正に大変感謝しています。 Otis Gospodnetic Kim Ryan Pete Ehlke Lupe Christoph David Birnbaum Achim Elizabeth Mattijsen (liz@dijkmat.nl) =head1 SEE ALSO Mail::Address, Net::DNS, Net::Domain::TLD, perlfaq9 =head1 翻訳について 翻訳者:IWAI, Masaharu Eiwaim.sub@gmail.comE Perlドキュメント日本語訳 Project にて、 Perlモジュール、ドキュメントの翻訳を行っております。 http://sourceforge.jp/projects/perldocjp/ http://www.freeml.com/ctrl/html/MLInfoForm/perldocjp@freeml.com http://perldoc.jp/ =cut