AW: Catching sent mail to wrong address....
"Luft, Markus" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <78CB79D4F16FFD4C8D7D1E557012AF28043AC150@derum202> |
I use the Net-DNS to lookup the domain names and check availability of mx
records.
#!/usr/bin/perl
#
use warnings;
use strict;
use IO::Socket;
use Net::DNS;
#
# Get the command line arguments.
#
die "Usage: $0 domain\n"
unless @ARGV==1;
my $domain = shift @ARGV;
# open a resolver resource
my $resolver = Net::DNS::Resolver->new();
# determine mx records for the domain
my @mx = mx($resolver, $domain);
# try to connect to each mx host - until one worked
foreach my $record (@mx) {
# open a socket to smtp port
my $client = IO::Socket::INET->new( $record->exchange . ":25");
my $answer = <$client>;
# an SMTP protocol answer which starts with 220 means ok
close( $client );
if( $answer =~ /^220 .*/) {
# domain ok
print "got 220 from " . $record->exchange . "\n";
exit 0;
}
}
I currently find nothing included in Mail::Box packages but I assume that
DNS will be handled seperately.
As far as I know you can't get surely get rid of
[email protected] because not every
MTA tells you about a non valid left side.
Regards
Markus Luft
-----Ursprüngliche Nachricht-----
Von: Kjetil Engen [mailto:[email protected]]
Gesendet: Montag, 15. März 2004 14:09
An: [email protected]
Betreff: Catching sent mail to wrong address....
I've been trying to find out "if" and "how" MailBox handles sending mail
with
wrong addresses.
With this I mean mails for:
[email protected]
and for:
[email protected]
So far I've though about catching [email protected] by
reply
from postmaster and mailerdeamon from some.random.server
But I'm totally stuck at trying to solve sending email with a faulty server
address.
Does anybody have any good MailBox-clues on both situations, or external
"fixes" to this problem?
Yours truly:
Kjetil Engen