[ale] Sending Mail in perl

Christopher Fowler cfowler at outpostsentinel.com
Sun May 4 21:24:07 EDT 2003



Guys/Gals,


Here is a snippet using Net::DNS to get the MX record
of an email address.  From that point forward, you can
use Geoff's script as well as Net::SMTP to send an
email directly to that address and avoid using 
a local relay.


---------------------------------
#!/usr/bin/perl

use Net::DNS;
die "$0 <email addr>\n" unless $ARGV[0];
$ARGV[0]=~ /.*\@(.*)/;
die "can not get domain\n" unless $1;
my @mx = mx($1);
foreach $rec (@mx) {
    print $rec->preference." ".$rec->exchange."\n";
}

# vi: set ts=4 sw=4 : 
---------------------------------

Chris

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list