-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Dave,
I’ve posted a really basic e-mail address verifier to
http://wiki.rubygarden.org/Ruby/page/show/VerifyEmailAddress
I’d appreciate folks who understand DNS and SMTP having a look at
it to see if it looks reasonable. You could comment here or,
possibly more usefully, comment on the wiki page itself.
I think this may fail with a email addresses that have quoted
local parts that contain “@”. Here’s a more restrictive regexp
that handles quoted local parts:
http://tfletcher.com/lib/rfc822.rb
My only problem with this regexp is it tests the email according to
the RFC 822 spec, which is looser than what is allowed in real-life.
For example, this regexp allows a host with any TLD to match, but
there are a limited number of TLDs that are issued by ICANN.
Also, the part of the code that checks the MX and A records can
probably be shortened to something like:
mx_hosts = dns.getresources(domain,
Resolv::DNS::Resource::IN::MX) rescue []
mx_hosts.sort_by { |mx| mx.preference }.map { |mx|
mx.exchange }.push(domain).each do |host|
a_records = dns.getresources(host.to_s,
Resolv::DNS::Resource::IN::A) rescue []
return false if check_hosts(a_records)
end
Thanks,
Dan
Dan K.
Autopilot Marketing Inc.
Email: [email protected]
Phone: 1 (604) 820-0212
Web: http://autopilotmarketing.com/
vCard: http://autopilotmarketing.com/~dan.kubb/vcard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)
iD8DBQFEbQQ94DfZD7OEWk0RAqq+AJsHJaD2D4XoLCJ57iQu0PeIe91dbQCgszCl
1/tPyLvgy4iIg7MLyoZO2RM=
=4Oqi
-----END PGP SIGNATURE-----