D
dan baker
I am trying to build a simple little script using MIME:Lite to run
through about 200 email addresses and send a simple text message. I
seem to be having a problem with a timeout as it gets though 5 or ten
addresses and then quits with the message:
Failed to connect to mail server: Bad file descriptor
I have tried sending a 'hello' every time, but that doesn't seem to
change the behavior....
I am running perl from ActiveState precompiled for windows98 on a PC,
and attempting to send via SMTP thru my server. I am wondering if
there is any way to disconnect and reconnect every 5 addresses or
something like that?
here is a snippet, with some error checking removed for brevity:
foreach $Recipient ( @tempList ) {
$First_Name = '';
$Last_Name = '';
$email = '';
$MarriedName = '';
# split the raw CSV textline
if ( $Recipient =~ m/"(.*)","(.*)","(.*)","(.*)"/ ) {
$First_Name = $1 ;
$Last_Name = $2 ;
$email = $3 ;
$MarriedName = $4 ;
}
$Recipient = "$First_Name $Last_Name";
if ( $MarriedName ) { $Recipient .= "-$MarriedName" }
$Recipient = "\"$Recipient\"\<$email\>";
# handshake server again
MIME::Lite->send('smtp', $cSMTPserver ,
Hello=>$cSMTPserver , Timeout=>60 );
# send mail
# -----
$msg='';
$msg = MIME::Lite->new(
From => $Sender ,
To => $Recipient ,
Subject => $Subject ,
Type => $Type ,
Data => $Body
);
unless ( $msg->send() ) { # send it now
print "...send FAILED \n\n";
}
}
through about 200 email addresses and send a simple text message. I
seem to be having a problem with a timeout as it gets though 5 or ten
addresses and then quits with the message:
Failed to connect to mail server: Bad file descriptor
I have tried sending a 'hello' every time, but that doesn't seem to
change the behavior....
I am running perl from ActiveState precompiled for windows98 on a PC,
and attempting to send via SMTP thru my server. I am wondering if
there is any way to disconnect and reconnect every 5 addresses or
something like that?
here is a snippet, with some error checking removed for brevity:
foreach $Recipient ( @tempList ) {
$First_Name = '';
$Last_Name = '';
$email = '';
$MarriedName = '';
# split the raw CSV textline
if ( $Recipient =~ m/"(.*)","(.*)","(.*)","(.*)"/ ) {
$First_Name = $1 ;
$Last_Name = $2 ;
$email = $3 ;
$MarriedName = $4 ;
}
$Recipient = "$First_Name $Last_Name";
if ( $MarriedName ) { $Recipient .= "-$MarriedName" }
$Recipient = "\"$Recipient\"\<$email\>";
# handshake server again
MIME::Lite->send('smtp', $cSMTPserver ,
Hello=>$cSMTPserver , Timeout=>60 );
# send mail
# -----
$msg='';
$msg = MIME::Lite->new(
From => $Sender ,
To => $Recipient ,
Subject => $Subject ,
Type => $Type ,
Data => $Body
);
unless ( $msg->send() ) { # send it now
print "...send FAILED \n\n";
}
}