2010-09-15 99 views
2

這可能是一個對SO和SF都有效的交叉問題。 我使用Perl腳本如下發送電子郵件:爲什麼Perl的MIME :: Lite失敗並顯示「SMTP data()命令失敗:2.1.5 ...收件人正常」?

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([email protected])}; 

close ERROR; 

現在這個腳本工作可愛的電子郵件的98%發..但是..大的2%的客戶是一個我我正試圖弄清楚。每當我發送到這個客戶端,特別是我得到的消息:SMTP數據()命令失敗:2.1.5 ...收件人好

有沒有人看過這個錯誤之前,或有任何想法,我的問題是哪裏?我試圖更換X-Mailer:標題,認爲這是垃圾郵件過濾。我嘗試將相同的消息發送給我們域上的其他人,並且僅適用於此客戶端網址。

例如下面標頭:

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 

任何線索?

此外,直接使用具有相同附件的Outlook發送電子郵件可與此客戶端和同一SMTP服務器完美協作。只有在通過這個自動化過程發送時,錯誤纔會帶來醜陋的頭腦。

更新: 調試日誌(已經我以爲這是在響應回來非同步大的延遲問題,並在MIME的過程沖水開展業務的正常流動::精簡版)

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

我看到你在'MIME :: Lite-> send'中啓用了'Debug'。你可以發佈該日誌嗎? – cjm 2010-09-15 22:43:07

+2

'嚴格使用;使用警告;' – Ether 2010-09-15 23:46:21

+0

好奇,如果它只是因爲你包含'body'而不是'html' /'head',或者如果這很重要? – vol7ron 2010-09-16 03:24:36

回答

3

Net :: SMTP客戶端似乎超時,但對RCTP TO的響應最終到達時,他們不再期望。嘗試將超時設置爲300秒而不是30秒?

+0

這是我在查看調試日誌序列之後在這一點上所假設的。有點擔心,如果每個其他客戶都沒有遇到這個問題,它會花費很長時間。我將測試一些不同的超時值。 – George 2010-09-16 13:49:27

+0

雖然不理想增加超時工作的情況下。感謝您的輸入。 – George 2010-09-16 14:54:45

+0

@George從該調試日誌中,您可以看到響應第一個RCPT TO需要90到120秒。你必須試驗看看是否一致。 – ysth 2010-09-16 16:16:32