[exim] Short Verify Perl Script

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Marc Perkel
Date:  
À: Exim, Users
Sujet: [exim] Short Verify Perl Script
Something a cobbled together. You real perl programmers could probably
improve it. I think it's useful as a troubleshooting tool.

#!/usr/bin/perl -w

# verify.pl
# usage: verify.pl email address

use IO::Socket::INET;
use Net::DNS;

$email_address=$ARGV[0];
print "\nEmail: $email_address\n";
@email=split(/@/,$email_address);

$lowest_pref=10000;
$lowest_mx='';

my $res = Net::DNS::Resolver->new;
my @mx = mx($res, $email[1]);

if (@mx) {
    foreach $rr (@mx) {
        if ($rr->preference < $lowest_pref) {
           $lowest_pref = $rr->preference;
           $lowest_mx = $rr->exchange;
        }
    }
} else {
    warn "Can't find MX records for $email[1]: ", $res->errorstring, "\n";
}


print "Server: $lowest_mx\n\n";

my $SOCKET = IO::Socket::INET->new("$lowest_mx:25");

my $RESPONSE = <$SOCKET>;

print $RESPONSE;

print "HELO junkemailfilter.com\n";
print $SOCKET "HELO junkemailfilter.com\n";

$RESPONSE = <$SOCKET>;
print $RESPONSE;

print "MAIL FROM:<>\n";
print $SOCKET "MAIL FROM:<>\n";

$RESPONSE = <$SOCKET>;
print $RESPONSE;

print "RCPT TO:$email_address\n";
print $SOCKET "RCPT TO: <$email_address>\n";

$RESPONSE = <$SOCKET>;
print $RESPONSE;