views:

145

answers:

1

This is probably a crossover question that is valid for both SO and SF. I am using a Perl script as follows to send e-mail:

my $SMTP_SERVER = 'xx.xx.xx.xx'; 
my $DEFAULT_SENDER = '[email protected]';      
my $DEFAULT_RECIPIENT = '[email protected]';

### Create the multipart "container":
$msg = MIME::Lite->new(
    From    =>$DEFAULT_SENDER,
    To      =>$input{to},
    Cc      =>$DEFAULT_SENDER,
    Subject =>$input{mailsubject},
    Type    =>'multipart/mixed'
);


my $msgbody="<body bgcolor=\"#C0C0C0\">\n";
   $msgbody.="<img src="cid:xyz.gif"><br>O hai thar.."
   $msgbody.="</body>";


### Add the text message part:
### (Note that "attach" has same arguments as "new"):
$msg->attach(
    Type     =>'text/html',
    Data     =>$msgbody
);

### Add the logo image part:    
$msg->attach(
    Type => 'image/gif',
    Id   => 'xyz.gif',
    Path => '/var/www/images/xyz.gif',
);


### Add the file part:
$msg->attach(
    Type        =>'application/zip',
    Path        =>$input{fullpath},
    Filename    =>$input{file},
    Disposition => 'attachment'
);

open ERROR,  '>>', "/debug/error.txt"  or die $!;
STDERR->fdopen( \*ERROR,  'w' );

eval{

# send the email
MIME::Lite->send('smtp', $SMTP_SERVER, Timeout=>30, Debug=>1, Notify => ['FAILURE','DELAY'], SkipBad => 1 );
$msg->send();

1;
}
or do{&error($@)};

close ERROR;

Now this script works lovely for 98% of the e-mails sent.. however.. the big 2% client is the one I am trying to figure out now. Whenever I send to this client in particular I get the message: SMTP data() command failed: 2.1.5 ... Recipient ok .

Has anyone seen this error before or have any idea as to where my problem is? I tried replacing the X-Mailer: header thinking that was being spam filtered. I tried sending the same message to others on our domain and that works just not to this client URL.

example header below:

MIME-Version: 1.0 
Content-Transfer-Encoding: binary 
Content-Type: multipart/mixed; 
boundary="_----------=_12845827796770" 
X-Mailer: MIME::Lite 3.027 (F2.76; T1.29; A2.03; B3.07_01; Q3.07) 
Date: Wed, 15 Sep 2010 13:37:59 -0700 
From: [email protected] 
To: [email protected], [email protected], [email protected] 
Cc: [email protected] 
Subject: TEST

Any clues?

Also, sending an e-mail directly using Outlook with same attachments works perfectly with this client and same smtp server. It is only when being sent via this automated process that the error rears it's ugly head.

Update: Debug Log (which has me thinking it is a big latency issue where the responses are coming back asynch and hosing up the normal flow of operations in the process of MIME::Lite)

MIME::Lite::SMTP>>> MIME::Lite::SMTP
MIME::Lite::SMTP>>>   Net::SMTP(2.31)
MIME::Lite::SMTP>>>     Net::Cmd(2.29)
MIME::Lite::SMTP>>>       Exporter(5.62)
MIME::Lite::SMTP>>>     IO::Socket::INET(1.31)
MIME::Lite::SMTP>>>       IO::Socket(1.30_01)
MIME::Lite::SMTP>>>         IO::Handle(1.27)
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 220 smpt.xxx.com ESMTP Sendmail 8.12.9/8.13.1; Wed, 15 Sep 2010 16:50:44 -0700 (PDT)
MIME::Lite::SMTP=GLOB(0x84ac258)>>> EHLO localhost.localdomain
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-smpt.xxx.com Hello [xx.xx.xx.xx], pleased to meet you
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-ENHANCEDSTATUSCODES
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-PIPELINING
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-8BITMIME
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-SIZE
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-DSN
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-ETRN
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250-DELIVERBY
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250 HELP
MIME::Lite::SMTP=GLOB(0x84ac258)>>> MAIL FROM:<[email protected]>
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250 2.1.0 <[email protected]>... Sender ok
MIME::Lite::SMTP=GLOB(0x84ac258)>>> RCPT TO:<[email protected]>
[Wed Sep 15 16:41:22 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
MIME::Lite::SMTP=GLOB(0x84ac258)>>> RCPT TO:<[email protected]>
[Wed Sep 15 16:41:52 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
MIME::Lite::SMTP=GLOB(0x84ac258)>>> RCPT TO:<[email protected]>
[Wed Sep 15 16:42:22 2010] myemailscript.cgi: MIME::Lite::SMTP=GLOB(0x84ac258): Timeout at /usr/local/share/perl/5.10.0/MIME/Lite.pm line 2889
MIME::Lite::SMTP=GLOB(0x84ac258)>>> RCPT TO:<[email protected]>
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250 2.1.5 <[email protected]>... Recipient ok
MIME::Lite::SMTP=GLOB(0x84ac258)>>> DATA
MIME::Lite::SMTP=GLOB(0x84ac258)<<< 250 2.1.5 <[email protected]>... Recipient ok
+2  A: 

The Net::SMTP client appears to be timing out, but the responses to the RCTP TO's are arriving eventually when they are no longer expected. Try setting the timeout to 300 seconds instead of 30?

ysth
That is what I was assuming at this point after reviewing the debug log sequence. Kind of concerned that it is taking so long when every other client is not having this issue. I am going to test out some different timeout values.
George
Although not ideal increasing the timeout worked for this case. Thanks for your input.
George
@George From that debug log, you can see it took between 90 and 120 seconds to respond to the first RCPT TO. You'd have to experiment to see if that's consistent.
ysth