2011-03-10 161 views
0

我配置了一個可通過本地主機訪問的SMTP服務器。CodeIgniter電子郵件不起作用

PHP郵件()命令工作正常,我在計劃的任務中使用它作爲附件的電子郵件備份。

如果我使用以下代碼使用CodeIgniter v1.7.2電子郵件庫,並且CI調試輸出顯示消息已發送,但SMTP服務器日誌顯示Bad Sender。

 $this->CI->load->library('email'); 

     $config['protocol'] = 'mail'; 
     $config['smtp_host'] = 'localhost'; 
     $config['mailtype'] = 'html'; 
     $config['crlf']  = "\r\n";  // CHANGED FROM DEFAULTS 
     $config['newline']  = "\r\n";  // CHANGED FROM DEFAULTS 

     $this->CI->email->initialize($config); 

     $this->CI->email->from('[email protected]'); 
     $this->CI->email->to($_POST['email']); 

     $this->CI->email->subject('Password Reset'); 
     $this->CI->email->message('Testing the email class. <a href="http://www.google.co.uk">test</a>'); 

     $this->CI->email->send(); 

這是從PHP郵件日誌2條消息(改變域hiddendomain1/2)

03/10/11 16:26:39 ME-I0107: [496] Relay Granted: Sender IP (127.0.0.1) is within an authorized IP range. 
03/10/11 16:26:39 ME-I0149: [496] AFAB1A79683B434EAD6A415C5DAA7D52.MAI was received successfully and delivery thread was initiated 
03/10/11 16:26:39 ME-I0074: [496] (Debug) End of conversation 
03/10/11 16:26:39 ME-I0107: [552] Relay Granted: Sender IP (127.0.0.1) is within an authorized IP range. 
03/10/11 16:26:39 ME-I0149: [552] 16B8D83CD6B040489608FCE5E9C3A177.MAI was received successfully and delivery thread was initiated 
03/10/11 16:26:39 ME-I0074: [552] (Debug) End of conversation 
03/10/11 16:26:40 ME-I0018: [8F72D521DC554A13AA1E0973090A75B9.MAI] Outbound message from ([SMTP:[email protected]]) requeued as [CC32D29A0BA34D9496B1602A8150B7EE.MAI] to the target domain [hiddendomain2.com] 
03/10/11 16:26:40 ME-I0123: Domain [hiddendomain2.com] has MX list [mailserver.hiddendomain2.com] 
03/10/11 16:26:40 ME-I0026: [CC32D29A0BA34D9496B1602A8150B7EE.MAI] Sending message 
03/10/11 16:26:40 ME-I0018: [9D2654AE500442E4A90DDFD75B98C0B5.MAI] Outbound message from ([SMTP:[email protected]]) requeued as [90EF8F85B103431FB14A32F535AFFFFD.MAI] to the target domain [hiddendomain2.com] 
03/10/11 16:26:40 ME-I0123: Domain [hiddendomain2.com] has MX list [mailserver.hiddendomain2.com] 
03/10/11 16:26:40 ME-I0026: [90EF8F85B103431FB14A32F535AFFFFD.MAI] Sending message 
03/10/11 16:26:40 ME-I0049: [CC32D29A0BA34D9496B1602A8150B7EE.MAI] Send Completed Successfully 
03/10/11 16:26:41 ME-I0049: [90EF8F85B103431FB14A32F535AFFFFD.MAI] Send Completed Successfully 

這是通過笨發送後的日誌,你可以看到CI電子郵件庫將< char添加到發件人地址,可以幫助告訴我爲什麼?這是CI的錯誤嗎?

03/10/11 16:26:42 ME-I0107: [568] Relay Granted: Sender IP (127.0.0.1) is within an authorized IP range. 
03/10/11 16:26:42 ME-I0149: [568] B1D7A0FCDF44403291E8EAD33F5F144F.MAI was received successfully and delivery thread was initiated 
03/10/11 16:26:42 ME-I0074: [568] (Debug) End of conversation 
03/10/11 16:26:42 ME-I0018: [38DFE013802046528FAC7823871869CC.MAI] Outbound message from ([SMTP:<[email protected]]) requeued as [AC83949E463246DDBD022BBF355D4606.MAI] to the target domain [hiddendomain2.com] 
03/10/11 16:26:42 ME-I0123: Domain [hiddendomain2.com] has MX list [mailserver.hiddendomain2.com] 
03/10/11 16:26:42 ME-I0026: [AC83949E463246DDBD022BBF355D4606.MAI] Sending message 
03/10/11 16:26:42 ME-IXXXX: [AC83949E463246DDBD022BBF355D4606.MAI] Remote server returned a response indicating a permanent error. Server Response: (501 Bad sender address syntax**) 
03/10/11 16:26:42 ME-E0036: [AC83949E463246DDBD022BBF355D4606.MAI] MAIL FROM command Failed. 
03/10/11 16:26:42 ME-E0008: [AC83949E463246DDBD022BBF355D4606.MAI] Outbound, could not send the command to the server (error 10038). 
03/10/11 16:26:42 ME-E0060: [AC83949E463246DDBD022BBF355D4606.MAI] - Message could not be delivered to target domain (hiddendomain2.com). Message returned to Sender. 
03/10/11 16:26:43 ME-I0119: Domain [hiddendomain1.com] has used local loopback address [127.0.0.1] because it is hosted locally. 
03/10/11 16:26:43 ME-I0026: [AC83949E463246DDBD022BBF355D4606.MAI] Sending message 
03/10/11 16:26:43 ME-I0102: [572] Address ([SMTP:<[email protected]]) is to be delivered to Catch-All address. 
03/10/11 16:26:43 ME-I0149: [572] CAEFBF802B8646DB99B4D2401571AE3E.MAI was received successfully and delivery thread was initiated 
03/10/11 16:26:43 ME-I0049: [AC83949E463246DDBD022BBF355D4606.MAI] Send Completed Successfully 
03/10/11 16:26:43 ME-I0074: [572] (Debug) End of conversation 
03/10/11 16:26:43 ME-I0132: Catch-All Message rendered for CAEFBF802B8646DB99B4D2401571AE3E.MAI 

它看起來的錯誤是這裏的報道,但迴避掉與SMTP服務器問題,但看來問題的確是與CI的lib兼容性問題:http://codeigniter.com/forums/viewthread/114030/

我很該死的肯定這是CI的問題,因爲PHP郵件工作正常。有人可以確認嗎?因爲如果不是,我需要更改我使用CI的腳本。我可以提供任何日誌/詳細信息

回答

1

我曾經有過同樣的問題,我沒有在我的代碼這種變化:

 
$config['protocol'] = 'smtp'; 
$config['validate'] = 'FALSE'; 

我希望爲你的作品