📜 ⬆️ ⬇️

Validation Email with verification of the MX-domain record

Using symfony with ORM Doctrine , it became necessary to check e-mail in shape, but the usual sfValidatorEmail is not enough, since if in the Doctrine data model, the email field is declared with the “email: true” validator, it is checked by Doctrine itself for the presence of the MX domain record, and if it is not present, it throws out an event. Agree, this is not beautiful (: The user enters the registration data and the fake mailing address that satisfies the pattern, and receives in reply “500 Inernal Server Error”.

For correct processing of fake addresses, I made my sfValidatorEmailMx validator, which inherits the standard sfValidatorEmail validator by checking the MX domain record, if there are no records, it causes an error "mx_error" and the domain name in the% domain% field.

Validator code (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 .


Using:
  1. <? php
  2. // ...
  3. $ this -> validatorSchema [ 'mail' ] = new sfValidatorEmailMx (array (), array (
  4. 'invalid' => 'E-Mail was entered incorrectly.' ,
  5. 'max_length' => 'Maximum length of email% max_length% characters.' ,
  6. 'mx_error' => 'There can be no% domain% mail on the server.' ,
  7. ))
* This source code was highlighted with Source Code Highlighter .

I would be glad if someone come in handy (:

')

Source: https://habr.com/ru/post/51240/


All Articles