ドメインMXレコード検証によるメール検証

symfonyとORM Doctrineを使用して、フォームのe-mail'aをチェックする必要がありましたが、通常のsfValidatorEmailでは十分ではありません。 DoctrineデータモデルでEメールフィールドが「email:true」バリデーターで宣言されている場合、Doctrine自身がMXドメインレコードの存在をチェックし、存在しない場合は実行をスローします。 同意します、これは美しくありません(:ユーザーが登録データとテンプレートに一致する偽の電子メールアドレスを入力し、応答で「500 Inernal Server Error」を受け取ります。



偽のアドレスを正しく処理するために、ドメインのMXレコードの検証を追加することで標準のsfValidatorEmailバリデータを継承するsfValidatorEmailMxバリデータを作成しました。エントリがない場合、エラー「mx_error」と%domain%フィールドにドメイン名が生成されます。



バリデーターコード(lib / validator / sfValidatorEmailMx.class.php):

<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  1. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  2. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  3. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  4. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  5. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  6. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  7. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  8. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  9. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  10. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  11. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  12. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  13. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  14. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  15. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  16. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  17. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  18. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  19. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  20. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  21. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  22. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  23. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  24. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  25. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  26. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  27. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  28. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  29. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  30. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  31. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  32. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  33. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  34. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  35. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  36. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  37. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  38. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  39. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  40. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  41. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  42. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



  43. <?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .



<?php /** * sfValidatorEmailMx validates emails width mx record. * * @package symfony * @subpackage validator * @author Rustam Miniakhmetov <pycmam[at]gmail.com> */ class sfValidatorEmailMx extends sfValidatorEmail { /** * @see sfValidatorEmail */ protected function configure($options = array(), $messages = array()) { parent::configure($options, $messages); $ this ->addMessage( 'mx_error' , 'No MX records for domain %domain%.' ); } protected function doClean($value) { $value = parent::doClean($value); list(,$domain) = explode( '@' , $value); if ($ this ->checkMx($domain)) { return $value; } else { throw new sfValidatorError($ this , 'mx_error' , array( 'domain' => $domain)); } } protected function checkMx($domain) { if (function_exists( 'checkdnsrr' )) { return ( bool )checkdnsrr($domain, 'MX' ); } else { return true ; } } } * This source code was highlighted with Source Code Highlighter .







使用法:





  1. <?php
  2. // ...
  3. $ this-> validatorSchema [ 'mail' ] = new sfValidatorEmailMx(array()、array(
  4. 「無効」 => 「電子メールが間違って入力されました。」
  5. 'max_length' => '電子メールの最大長%max_length%文字。
  6. 'mx_error' => 'server%domain%にメールが存在しない可能性があります。
  7. ));
*このソースコードは、 ソースコードハイライターで強調表示されました。


誰かが便利になるとうれしいです:



All Articles