Email Address Validator plugin
Plugin details
Documentation
ruby script/plugin install http://www.hezmatt.org/~mpalmer/darcs/email_address_validator.trunk
Usage Examples
=================
The only method you should really need to call to make things work is ::validate. This method takes an e-mail address as it's sole argument, and returns true or false based on whether the address is valid or not.
If you just want regex validation, all you need to do is call ::validate:
EmailAddressValidation.validate('me@example.com')
This will return either true or false depending on whether the address matches the regular expression. To turn on DNS lookups, you need to set the check_dns flag on the class:
EmailAddressValidation.check_dns = true
Then calling ::validate will do MX/A record lookups on the domain, as well as the regex check. To enable full delivery attempt checks, turn on check_mx and, optionally, provide an FQDN to use in the HELO. We'll try to guess an appropriate value if none is given, but it's quite common for the hostname of a machine to not be resolvable, which can give incorrect results. You must ensure that there is a valid HELO domain, one way or another, if you want to expect good results.
EmailAddressValidation.check_mx = true EmailAddressValidation.helo_domain = 'example.org'
Since a delivery attempt can take a long time in certain pathological cases, we have a timeout set for each attempt to deliver to an MX. By default, the timeout is set to 5 seconds (a nice median value), but you can change it to either be longer (which will reduce false negatives) or shorter, if you need better responsiveness (at the expense of more false negatives):
EmailAddressValidation.timeout = 10
The value is in seconds, and it applies to each MX that is looked up -- so a domain with a large number of MXes can still take quite a while to complete a lookup. If you have a need to limit the total time taken for a validation, you should wrap the validate call in your own timeout block.
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago


