目前,我正在尝试将Mandrill功能集成到Zend 1遗留应用程序中,而且我对它们处理邮件传输的方式不太熟悉。目前,我正在包含mandrill/mandrill
作曲家包,并试图遵循Zend 1中包含的其他传输层的模式:
class MandrillTransport extends Zend_Mail_Transport_Abstract
{
private $message = array();
protected function _formatMandrillArray()
{
//grab all the relavant data from the pre-existing mail object and put it into a Mandrill-friendly array
}
protected function _getAttachments() {
//loop through and format attachments that get added to array
}
protected function _sendMail()
{
//send Mandrill message with included data
$mandrill = new Mandrill(Zend::registry('config')->mandrill->APIKey);
$mandrill->messages->send($this->message);
}
public function send() {
//Format all the stuff and send it
}
}
然后我假设我可以在“send()”函数中使用它,它似乎将传输作为参数:
//TODO: Put this in a better spot
require_once __DIR__ . "/ZendFramework/Zend/Mail/Transport/MandrillTransport.php";
$tr = new MandrillTransport();
$email->send($tr);
我在这里走在正确的轨道上吗?我之所以要将其作为传输层而不是仅仅删除现有代码并将其替换为Mandrill,是因为有很多不同的业务流程发送邮件,我们希望能够选择和选择哪个使用Sendmail传输,哪些使用Mandrill。
提前致谢, -Chris