=encoding euc-jp =head1 NAME Email::Valid - インターネット電子メールアドレスの正当性のチェック =head1 SYNOPSIS use Email::Valid; print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no'); =head1 DESCRIPTION This module determines whether an email address is well-formed, and optionally, whether a mail host exists for the domain. このモジュールは、電子メールアドレスが適格であるか否かを判断します。 さらに、そのドメインのメールホストが存在するか否かも判断します。 Please note that there is no way to determine whether an address is deliverable without attempting delivery (for details, see perlfaq 9). 実際に配送することなしに電子メールアドレスが配送可能か否かを 判断することはできないということに留意してください。 (詳細については、perlfaq 9 を見てください。) =head1 PREREQUISITES 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. このモジュールは perl 5.004 以降と Mail::Address を要求します。 また、DNS チェックのために Net::DNS モジュールか nslookup ユーティリティのどちらかを要求します。 =head1 METHODS 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.
パラメータを受け取るための全てのメソッドには、 文字列か Mail::Address クラスのインスタンスのどちらかを 渡すことができます。全てのエラーには例外が発生します。 =over 4 =item new ( [PARAMS] ) 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. このメソッドは、Email::Valid オブジェクトを生成します。 パラメータの名前のオプションのリストを渡すことによって オブジェクトの振る舞いを変更することができます。 The following named parameters are allowed. See the individual methods below of details. 許可されているパラメータの名前は次のものです。 個々の詳細は下にある説明を見てください。 -mxcheck -fudge -fqdn -local_rules =item mx (
| ) This method accepts an email address or domain name and determines whether a DNS record (A or MX) exists for it. このメソッドは、電子メールアドレスかドメイン名を渡すことによって、 (A か MX の)DNS レコードが存在するか否かを判断します。 The method returns true if a record is found and undef if not. このメソッドはレコードが見つかったならば true を、そうでない ならば undef を返します。 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. DNS チェックには、Net::DNS モジュールか nslookup ユーティリティの どちらかが必要です。Net::DNS モジュールを用いた方が、良いエラー ハンドリングを得ることができます。もし、Net::DNS モジュールが 利用できるならば、あなたは $Email::Valid::Resolver に格納されている グローバルな Net::DNS::Resolver インスタンスの操作によって (例えば tcp_timeout の初期値を変更するなどの)レゾルバの振る舞いを 変更することができます。 =item rfc822 (
) 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. このメソッドは、アドレスが RFC822 の仕様に従っているか否かを 判断します。但し、ネストしたコメントには対応していません。 仕様に従っているならば true を、そうでないならば undef を返します。 =item fudge ( | ) 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. address() が呼ばれた際に、一般的なアドレスのエラーがあれば 修正しようと試みます。今のところは、AOL のアドレスの場合は、 空白文字を削除し、Compuserve アドレスの場合は、コンマをピリオドに 置換します。初期値は false です。 =item fqdn ( | ) Species whether addresses passed to address() must contain a fully qualified domain name (FQDN). The default is true. address() にアドレスが渡されたときに正規の完全なドメイン名(FQDN)を 持つのかをチェックします。初期値は true です。 =item local_rules ( | ) 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. address() にアドレスが渡されたときに特定の制約事項を持つドメインの アドレスをチェックします。今のところは AOL の制約事項の検出に 限定されています。初期値は false です。 =item mxcheck ( | ) Specifies whether addresses passed to address() should be checked for a valid DNS entry. The default is false. address() にアドレスが渡されたときに正しい DNS エントリーで あるのかをチェックします。初期値は false です。 =item address (
) This is the primary method which determines whether an email address is valid. It's behavior is modified by the values of mxcheck(), 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. 電子メールアドレスが正当である(valid)か否かを判断するための 主要な(primary)メソッドです。mxcheck() や local_rules()、 fqdn()、fudge() の値によって振る舞いを変更できます。もし、 アドレスが全てのチェックで問題がなかったならば、 (場合によっては修正された)アドレスを文字列として返します。 そうでなければ、未定義値を返します。リストコンテキストならば、 電子メールアドレスを表現するクラスである Mail::Address の インスタンスも返します。 =item details () If the last call to address() returned undef, you can call this method to determine why it failed. Possible values are: 最後に呼ばれた address() が undef を返したときに、 どのチェック項目で失敗したのかを返します。 次の値が用意されています。 rfc822 local_rules fqdn mxcheck If the class is not instantiated, you can get the same information from the global $Email::Valid::Details. もし、クラスのインスタンスを生成していないならば、グローバル変数 $Email::Valid::Details から同様の情報を得ることができます。 =back =head1 EXAMPLES Let's see if the address 'maurice@hevanet.com' conforms to the RFC822 specification: それでは、RFC822 の仕様に従っている 'maurice@hevanet.com' という アドレスでの例を見てみましょう。 print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no'); Additionally, let's make sure there's a mail host for it: 更に、メールホストを確認してみましょう。 print (Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ) ? 'yes' : 'no'); Let's see an example of how the address may be modified: アドレスを修正する場合の例を見てみましょう。 $addr = Email::Valid->address('Alfred Neuman '); print "$addr\n"; # prints Neuman@foo.bar Need to determine why an address failed? 何故アドレスが正しくないのかの理由が必要な場合は次のようになります。 unless(Email::Valid->address('maurice@hevanet')) { print "address failed $Email::Valid::Details check.\n"; } 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: エラーがあった場合に例外を発生させます。これは、DNS クエリを実行 したときだけ使えます。eval ブロックで括ることによって、 例外を捕捉します。 eval { $addr = Email::Valid->address( -address => 'maurice@hevanet.com', -mxcheck => 1 ); }; warn "an error was encountered: $@" if $@; =head1 BUGS 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. Email::Valid は Perl for Win32 で動作します。しかし、私の経験では、 Net::DNS クエリを使ったとしても、レコードを見つけることが できなかった際に極めて長い時間待たされるように思います。 =head1 AUTHOR Copyright 1998-1999, 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 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. このモジュールの大部分は、Tom Christiansen によって書かれた ckaddr プログラムと Jeffrey Friedl によって書かれた RFC822 アドレスの正規表現 をベースにしています。このモジュールの構造は複雑ではありません。 また、全てのエラーは私自身に責任があります。 Thanks very much to the following people for their suggestions and bug fixes: 下に挙げる人々の示唆やバグ修正に大変感謝しています。 Otis Gospodnetic Kim Ryan Pete Ehlke Lupe Christoph David Birnbaum Achim =head1 SEE ALSO Mail::Address, Net::DNS, 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