2013-01-09 62 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