sylvaindeloux / symfony-mailjet-transport
0.6
2022-05-26 10:58 UTC
Requires
- php: ^7.1||^8.0
- symfony/http-client: ^4.4||^5.0||^6.0
- symfony/mailer: ^4.4||^5.0||^6.0
Requires (Dev)
README
已弃用仓库
由于 Mailjet 已被 Symfony 团队添加到 symfony/mailjet-mailer
,此软件包将不会进一步发展。
安装
安装软件包
composer require sylvaindeloux/symfony-mailjet-transport
将其添加到 config/bundles.php
<?php
return [
// ...
SylvainDeloux\MailjetTransport\MailjetTransportBundle::class => ['all' => true],
];
现在您可以使用 Mailjet 账户与 Symfony Mailer 一起使用。您只需配置 MAILER_DSN
环境变量并使用您的凭证即可
- SMTP:
mailjet+smtp://<您的 API 密钥>:<您的 API 密码>@in-v3.mailjet.com
- API:
mailjet+api://<您的 API 密钥>:<您的 API 密码>@api.mailjet.com?version=3.1
使用带有变量的 Mailjet 模板
如果您想使用自定义模板而不是 Twig HTML / 文本正文,并注入自己的变量
$email = (new \SylvainDeloux\MailjetTransport\Mailer\Email())
// ...
->setTemplateId(<your template id>)
->setErrorReportingEmail(<your email address for debugging>) // optional, to get a detailled message if template error occurs
->setTemplateErrorDeliver() // optional, if you want the mail to be delivered if template error occurs
->setVariables(array(
'key' => 'value',
))
;