Mail-Verify-0.02/ 40755 1751 3720 0 7500673610 12177 5ustar petefstaffMail-Verify-0.02/lib/ 40755 1751 3720 0 7500673610 12745 5ustar petefstaffMail-Verify-0.02/lib/Mail/ 40755 1751 3720 0 7500673610 13627 5ustar petefstaffMail-Verify-0.02/lib/Mail/Verify.pm100644 1751 3720 5644 7500673550 15542 0ustar petefstaff# Mail::Verify.pm # $Id: Verify.pm,v 1.4 2002/06/09 15:42:32 petef Exp $ # Copyright (c) 2001 Pete Fritchman . All rights # reserved. This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Mail::Verify; =head1 NAME Mail::Verify - Utility to verify an email address =head1 SYNOPSIS use Mail::Verify; =head1 DESCRIPTION C provides a function CheckAddress function for verifying email addresses. First the syntax of the email address is checked, then it verifies that there is at least one valid MX server accepting email for the domain. Using L and L a list of MX records (or, falling back on a hosts A record) are checked to make sure at least one SMTP server is accepting connections. =head1 ERRORS Here are a list of return codes and what they mean: =item 0 The email address appears to be valid. =item 1 No email address was supplied. =item 2 There is a syntaxical error in the email address. =item 3 There are no DNS entries for the host in question (no MX records or A records). =item 4 There are no live SMTP servers accepting connections for this email address. =head1 EXAMPLES This example shows obtaining an email address from a form field and verifying it. use CGI qw/:standard/; use Mail::Verify; my $q = new CGI; [...] my $email = $q->param("emailaddr"); my $email_ck = Mail::Verify::CheckAddress( $email ); if( $email_ck ) { print '

Form input error: Invalid email address.

'; } [...] =cut use strict; use IO::Socket; use Net::DNS; my $VERSION = "0.02"; my $DEBUG = "0"; sub Version { $VERSION } sub CheckAddress { my $addr = shift; return 1 unless $addr; my ($rr, @mxhosts, @mxrr, $resolver, $dnsquery, $livesmtp, $mx); my ($testsmtp); # First, we check the basic syntax of the email address. my ($user, $domain, $extra); ($user, $domain, $extra) = split /\@/, $addr; return 2 if $extra; @mxrr = Net::DNS::mx( $domain ); # Get the A record for each MX RR foreach $rr ( @mxrr ) { push( @mxhosts, $rr->exchange ); } if( ! @mxhosts ) { # check for an A record... $resolver = new Net::DNS::Resolver; $dnsquery = $resolver->search( $domain ); return 3 unless $dnsquery; foreach $rr ($dnsquery->answer) { next unless $rr->type eq "A"; push( @mxhosts, $rr->address ); } return 3 unless @mxhosts; } # DEBUG: see what's in @mxhosts if( $DEBUG ) { foreach( @mxhosts ) { $mx = $_; print STDERR "\@mxhosts -> $mx\n"; } } # make sure we have a living smtp server on at least one of @mxhosts $livesmtp = 0; foreach $mx (@mxhosts) { $testsmtp = IO::Socket::INET->new( Proto=>"tcp", PeerAddr=> $mx, PeerPort=> 25, Timeout => 10 ); if( $testsmtp ) { $livesmtp = 1; close $testsmtp; } } if( ! $livesmtp ) { return 4; } return 0; } 1; Mail-Verify-0.02/ChangeLog100644 1751 3720 1063 7500673547 14057 0ustar petefstaff# $Id: ChangeLog,v 1.7 2002/06/09 15:42:31 petef Exp $ * 7/26/2001 13:56:46 EDT - Pete Fritchman - Initial revision complete (version 0.01) * 7/26/2001 14:31:51 EDT - Pete Fritchman - CVS Id tags added - Version 0.01 uploaded to CPAN * 6/9/2001 11:37:44 EDT - Detlef von der Huelst - add "use strict", this fixes some bugs in the way i was using scope * 6/9/2001 11:42:39 EDT - CPAN Tester - add a basic test * 6/9/2001 11:43:39 EDT - Pete Fritchman 'Pete Fritchman ', 'NAME' => 'Mail::Verify', 'VERSION_FROM' => 'lib/Mail/Verify.pm', 'PREREQ_PM' => { 'IO::Socket' => 0.1, 'Net::DNS' => 0.1, }, 'dist' => {COMPRESS => 'gzip', SUFFIX => 'gz' }, ); Mail-Verify-0.02/README100644 1751 3720 2611 7330061167 13153 0ustar petefstaff# $Id: README,v 1.1.1.1 2001/07/26 18:33:27 petef Exp $ NAME Mail::Verify - Utility to verify an email address SYNOPSIS use Mail::Verify; DESCRIPTION `Mail::Verify' provides a function CheckAddress function for verifying email addresses. First the syntax of the email address is checked, then it verifies that there is at least one valid MX server accepting email for the domain. Using the Net::DNS manpage and the IO::Socket manpage a list of MX records (or, falling back on a hosts A record) are checked to make sure at least one SMTP server is accepting connections. ERRORS Here are a list of return codes and what they mean: 0 The email address appears to be valid. 1 No email address was supplied. 2 There is a syntaxical error in the email address. 3 There are no DNS entries for the host in question (no MX records or A records). 4 There are no live SMTP servers accepting connections for this email address. EXAMPLES This example shows obtaining an email address from a form field and verifying it. use CGI qw/:standard/; use Mail::Verify; my $q = new CGI; [...] my $email = $q->param("emailaddr"); my $email_ck = Mail::Verify::CheckAddress( $email ); if( $email_ck ) { print '

Form input error: Invalid email address.

'; } [...] Mail-Verify-0.02/TODO100644 1751 3720 646 7330061167 12751 0ustar petefstaff# $Id: TODO,v 1.1.1.1 2001/07/26 18:33:27 petef Exp $ * Better comments maybe? * Try to use EXPN and/or VRFY * Check characters in email address for RFC compliance * Make an object that would be used to verify the email address, and have PrintError and other methods * Fix PREREQ_PM in Makefile.PL to actually point to the version numbers required (I didn't have time to look through the respective ChangeLogs) Mail-Verify-0.02/t/ 40755 1751 3720 0 7500673610 12442 5ustar petefstaffMail-Verify-0.02/t/use.t100644 1751 3720 157 7500673404 13504 0ustar petefstaff#!/usr/bin/env perl -w use strict; use Test; BEGIN { plan tests => 1 } use Mail::Verify; ok(1); exit; __END__