zend_mail中return-path的问题


issues with return-path in zend_mail

请告诉我为什么我使用zend_mail设置returnPath收到的电子邮件必须使用smtp传输返回路径头(我在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相同的我设置从头。这是Zend_Mail的bug还是什么?我的理解是正确的,服务器将添加返回路径头相同,因为它在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;
}   

在Zend中,您可以通过显式选择传输将必要的附加参数传递给sendmail:

$tr = new Zend_Mail_Transport_Sendmail('-fmail@example.com');
 $_mail = new Zend_Mail();
 $_mail->setDefaultTransport($tr);

try this:

$mail->addHeader('Return-path', 'email@address.com');