# It can be redistributed and/or modified under the same terms under
# which Perl itself is published.
# It can be redistributed and/or modified under the same terms under
# which Perl itself is published.
################################# Configuration ################################
# Please fill in a working configuration!
################################# Configuration ################################
# Please fill in a working configuration!
# display usage information if neither -f nor an address are present
if (!$options{'f'} and !$ARGV[0]) {
# display usage information if neither -f nor an address are present
if (!$options{'f'} and !$ARGV[0]) {
print "Options: -V display copyright and version\n";
print " -h show documentation\n";
print " -q quiet (no output, just exit with 0/1/2/3)\n";
print " -l extended logging\n";
print " -r test random address to verify verification\n";
print " -m <host> no DNS lookup, just test this host\n";
print "Options: -V display copyright and version\n";
print " -h show documentation\n";
print " -q quiet (no output, just exit with 0/1/2/3)\n";
print " -l extended logging\n";
print " -r test random address to verify verification\n";
print " -m <host> no DNS lookup, just test this host\n";
print " <address> mail address to check\n\n";
print " -f <file> parse file (one address per line)\n";
exit(100);
};
print " <address> mail address to check\n\n";
print " -f <file> parse file (one address per line)\n";
exit(100);
};
my (%targets,$curstat,$status,$log,$message);
foreach (@addresses) {
my $address = $_;
my (%targets,$curstat,$status,$log,$message);
foreach (@addresses) {
my $address = $_;
printf(" * Testing %s ...\n",$address) if !($options{'q'});
$log .= "\n===== BEGIN $address =====\n";
# get list of target hosts or take host forced via -m
printf(" * Testing %s ...\n",$address) if !($options{'q'});
$log .= "\n===== BEGIN $address =====\n";
# get list of target hosts or take host forced via -m
- (undef,my $domain) = splitaddress($address);
- my ($success,$code,@message) = try_rcpt_to(\$smtp,create_rand_addr($domain),$logr);
+ my ($success,$code,@message) = try_rcpt_to(\$smtp,create_rand_addr(Mail::Address->new('',$address)->host),$logr);
-################################# splitaddress #################################
-# split mail address into local and domain part
-# IN : $address: a mail address
-# OUT: $local : local part
-# $domain: domain part
-sub splitaddress {
- my($address)=@_;
- (my $lp = $address) =~ s/^([^@]+)@.*/$1/;
- (my $domain = $address) =~ s/[^@]+\@(\S*)$/$1/;
- return ($lp,$domain);
-};
-
############################### create_rand_addr ###############################
# create a random mail address
# IN : $domain: the domain part
############################### create_rand_addr ###############################
# create a random mail address
# IN : $domain: the domain part