You guys rock! blessing is the key! So basically I'm testing a socket to see if it's good, and then sending mail if its good like this:
my $sock = new IO::Socket::INET->new(PeerPort => 25,
PeerAddr => 'PEERADDR',
Proto => 'tcp',
LocalAddr => 'LOCALADDR' )
or die "Can't bind : $@\n";
$sock->recv($_, 2048);
if(/^220/) {
print "Connection OK!\n";
bless $sock, 'Net::SMTP';
$smtp = $sock;
}
else {
print "Connection BAD!\n";
exit 1;
}
$smtp->mail($mail_from);
$smtp->recipient($rcpt_to);
$smtp->data;
$smtp->datasend("From: $from\r\n");
$smtp->datasend("To: $to\r\n");
$smtp->datasend("Subject: $subject\r\n");
$smtp->datasend("\r\n");
$smtp->datasend("$body\r\n");
and so far (as of 5 minutes ago) it seems to be working!
If there is something totally wrong with this please let me know, otherwise, thanks so much for the information!
| [reply] |