0

我刚刚为 Zend Framework 2 创建了一个邮件程序类。它使用了 Sendmail 类。

问题是我用多个单词设置了电子邮件的主题。在发送之前,我转储了主题,所有空格都可以。发送电子邮件后,我检查了我的 gmail,主题中的所有空格都被删除了。

当我运行脚本时,我得到“testemail”作为主题。

在我创建的课程的一部分下面:

public function addFile($p_sPath, $p_sMimetype, $p_sFilename){
    $rFile = fopen($p_sPath,'rb');
    $this->_m_oAttachment = new Mimepart(fread($rFile,filesize($p_sPath)));
    $this->_m_oAttachment->type = $p_sMimetype;
    $this->_m_oAttachment->filename = $p_sFilename;
    $this->_m_oAttachment->disposition = 'attachment';
    $this->_m_oAttachment->encoding = Mime::ENCODING_BASE64;
}


public function sendEmail()
{
    $aParts = (!is_null($this->_m_oAttachment)) 
            ? array($this->_m_oBodymessage, $this->_m_oAttachment) 
            : array($this->_m_oBodymessage);

    $this->_m_oBodypart->setParts($aParts);

    $this->_m_oMessage->setEncoding('utf-8')
                      ->setBody($this->_m_oBodypart)
                      ->addFrom($this->_fromAddress, $this->_fromName)
                      ->addReplyTo($this->_fromAddress, $this->_fromName)
                      ->setSubject($this->_subject);
                      // even here the spaces are still intact.
    $this->send($this->_m_oMessage);
}



$oMailer = $this->getLocator()->get('Core\Mailer');
$oMailer->setBodyHtml('mail/mail.phtml', array('aData' => $aData));
$oMailer->setSubject('test email');
$oMailer->setRecipient('jacob@myemail.com', 'jacob');
$oMailer->addFile(realpath(dirname(__file__). '/../../../../../'.$sPath.$sSubfolder.'/'.$sFilename), 'application/pdf', $aData['data']['eventID'].'_'.$aDeclaratie['data']['userID'].'.pdf');
$oMailer->sendEmail();
4

1 回答 1

2

Zend Framework 2 stable 解决了这个问题

http://framework.zend.com/issues/browse/ZF2-258

于 2012-09-09T09:53:19.910 回答