我正在尝试通过mailjet在我的zend应用上发送电子邮件。它可以工作,但无法加载所需的模板。代码:
$config = array('ssl' => 'ssl',
'port' => 465,
'auth' => 'login',
'username' => 'mailjet api username',
'password' => '8mailjet api key');
$transport = new Zend_Mail_Transport_Smtp('in-v3.mailjet.com', $config);
$mail = new Zend_Mail();
$mail->addHeader('X-MJ-TemplateLanguage',true);
$mail->addHeader('X-MJ-TemplateID','validationV2');
// This is the template I wanna use.(above)
$mail->setFrom('test@test.org', 'You');
$mail->addTo('test@test.org', 'Anybody');
$mail->setSubject('My first email by Mailjet');
$mail->setBodyHtml('wxxxxxxxxxxxxxxxxxxxxxxxxx');
$mail->send($transport);如果我能得到任何帮助,那就太好了!
发布于 2017-09-07 15:29:25
您可以尝试将模板的数字ID放在X-MJ-TemplateID中。如果它仍然不起作用,请提交一个support ticket
发布于 2018-08-22 23:52:27
我遇到了同样的问题。这可能是邮件v3的SMTP中继不兼容Zend。
但是,我测试的解决方法是在通过composer导入' Mailjet /mailjet-apiv3-php‘后直接使用mailjet API,如下所示:
$mail = [
'FromEmail' => 'test@test.org',
'FromName' => 'You',
'To' => 'Anybody <test@test.org>,
'MJ-TemplateID' => 1,
'MJ-TemplateLanguage' => true
];
$mj = new Client('mailjet api username', '8mailjet api key');
$mj->post(Resources::$Email, ['body' => $mail]);然而,我很好奇Mailjet对你的支持票的回答是什么!
https://stackoverflow.com/questions/46057847
复制相似问题