你能否告诉我为什么我使用zend_mail设置returnPath收到的电子邮件必须使用smtp trasport返回路径标题(我在gmail中查看):
Return-Path: <bounce@domain.com> //I think this is added by server
.....
Return-Path: bounce@domain.com //I think this is cause by returnPath
我设置了这样的返回路径:
$mailer->setReturnPath('bounce@domain.com');
我设置了这样的传输:
$emailConfig = $this->getOption('email');
$transport = new Zend_Mail_Transport_Smtp($emailConfig['server'], $emailConfig);
Zend_Mail::setDefaultTransport($transport);
如果我没有设置returnPath服务器,则添加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;
}
答案 0 :(得分:0)
在Zend中,您可以通过明确选择传输来将必要的附加参数传递给sendmail:
$tr = new Zend_Mail_Transport_Sendmail('-fmail@example.com');
$_mail = new Zend_Mail();
$_mail->setDefaultTransport($tr);
答案 1 :(得分:-2)
试试这个:
$mail->addHeader('Return-path', 'email@address.com');