Program: expn and vrfy
This program talks directly to an SMTP server and uses the EXPN and VRFY commands to figure out whether an address is going to work. It isn’t perfect, because it relies on the remote SMTP giving meaningful information with the EXPN and VRFY commands. It uses Net::DNS if available, but can also work without.
This program inspects $0
(the program name) to see
how it was called. If run as expn, it uses the
EXPN command; if called as vrfy, it uses the
VRFY command. Use links to install it with two names:
% cat > expn #!/usr/bin/perl -w ... ^D % ln expn vrfy
When you run it with an email address, the program reports what the mail server says when you try to EXPN or VRFY the address. If you have Net::DNS installed, it tries all hosts listed as mail exchangers in the DNS entry for the address.
Here’s what it looks like without Net::DNS:
% expn gnat@frii.com
Expanding gnat at frii.com (gnat@frii.com):
calisto.frii.com Hello coprolith.frii.com [207.46.130.14],
pleased to meet you
<gnat@mail.frii.com>
And here’s the same address with Net::DNS installed:
% expn gnat@frii.com
Expanding gnat at mail.frii.net (gnat@frii.com):
deimos.frii.com Hello coprolith.frii.com [207.46.130.14],
pleased to meet you
Nathan Torkington <gnat@deimos.frii.com>
Expanding gnat at mx1.frii.net (gnat@frii.com):
phobos.frii.com Hello coprolith.frii.com [207.46.130.14],
pleased to meet you
E
<gnat@mail.frii.com>
xpanding gnat at mx2.frii.net (gnat@frii.com):
europa.frii.com Hello coprolith.frii.com ...
Get Perl Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.