2013-01-09 60 views
1

你能告訴我,爲什麼我設置ReturnPath這樣使用的Zend_Mail接收到的電子郵件返回路徑頭使用SMTP服務區域(我在Gmail中查看它們):問題與使用Zend_Mail返回路徑

Return-Path: <[email protected]> //I think this is added by server 
..... 
Return-Path: [email protected] //I think this is cause by returnPath 

我設定的回報-path這樣的:

$mailer->setReturnPath('[email protected]'); 

我集運輸這樣的:

$emailConfig = $this->getOption('email');         
$transport = new Zend_Mail_Transport_Smtp($emailConfig['server'], $emailConfig); 
Zend_Mail::setDefaultTransport($transport); 

如果我不設置ReturnPath這樣的服務器添加換貨政...路徑與我設置的From標題相同。 這是Zend_Mail中的錯誤還是什麼?我的理解是正確的,服務器將添加返回路徑頭文件與MAIL_FROM中使用的相同,並且setReturnPath不應該人爲添加頭文件,而只是將其保存爲用於MAIL_FROM? 它在Zend_Mail_Transport_Smtp對象改變代碼註釋行:

/** 
* Sets the Return-Path header of the message 
* 
* @param string $email 
* @return Zend_Mail Provides fluent interface 
* @throws Zend_Mail_Exception if set multiple times 
*/ 
public function setReturnPath($email) 
{ 
    if ($this->_returnPath === null) { 
     $email = $this->_filterEmail($email); 
     $this->_returnPath = $email; 

     //This line presents in Zend_Framework 
     //I comment this like I get only one return-path the same as 
     //set using setReturnPath method of Zend_Mail 
     //$this->_storeHeader('Return-Path', $email, false); 
    } else { 
     /** 
     * @see Zend_Mail_Exception 
     */ 
     require_once 'Zend/Mail/Exception.php'; 
     throw new Zend_Mail_Exception('Return-Path Header set twice'); 
    } 
    return $this; 
} 

回答

-2

試試這個:

$mail->addHeader('Return-path', '[email protected]'); 
+0

難道你在回答之前寫下問題? – Oleg

+0

除了addHeader是不正確的方式來設置標準頭,並會失敗。 – Oleg

+1

所以我不知道爲什麼它爲我工作 –

0

在Zend的,你可以通過必要的附加參數通過明確選擇的交通工具了sendmail:

$tr = new Zend_Mail_Transport_Sendmail('[email protected]'); 
$_mail = new Zend_Mail(); 
$_mail->setDefaultTransport($tr); 
+0

在[Mario的博客]上找到了這個(https://mariobrandt.de/archives/php/zend-framework-mail-bounce- because-of-return-path-540/) – Andy