0
我剛剛爲Zend Framework 2創建了一個郵件類。它使用Sendmail類。Sendmail ZF2空間剝離主題
問題是我用多個詞設置電子郵件的主題。發送之前,我轉儲主題,所有的空間都可以。在發送電子郵件之後,我檢查了我的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('[email protected]', 'jacob');
$oMailer->addFile(realpath(dirname(__file__). '/../../../../../'.$sPath.$sSubfolder.'/'.$sFilename), 'application/pdf', $aData['data']['eventID'].'_'.$aDeclaratie['data']['userID'].'.pdf');
$oMailer->sendEmail();