将 Postmark 与 Symfony Mailer 集成的问题

Problems integrating Postmark with Symfony Mailer

我目前正在努力尝试将 Postmark 与 Symfony5 Mailer Bundle 一起使用。虽然文档看起来很清楚,但我无法发送任何电子邮件。

我的第一个困惑是建议的邮戳 DSN 格式:

邮戳+smtp://ID@default

似乎不​​清楚应该使用什么 ID,因为 Postmark 为 SMTP 提供了用户名和密码,以及访问密钥和密钥(SMTP 令牌)。未按要求提供 ID。

有谁知道这里应该使用什么配置?

提前致谢!

到目前为止,我刚刚开始使用 To、CC 和 BCC。

我没有使用 Symfony5,但在我们的应用程序中实现了 SmyonfyMailer。

我必须安装的软件包:

composer require symfony/mailer
composer require symfony/postmark-mailer
composer require symfony/http-client

如果您实例化 symfony 邮件程序 class,您可以像这样传递传输对象(我使用 API,而不是 SMTP)。


use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;

$dsn = 'postmark+api://' . <postmark-api-key> . '@default';

$transport = Transport::fromDsn($dsn);

$mailer = new Mailer($transport);

$email = (new Email())
            ->from('hello@example.com')
            ->to('you@example.com')
            //->cc('cc@example.com')
            //->bcc('bcc@example.com')
            //->replyTo('fabien@example.com')
            //->priority(Email::PRIORITY_HIGH)
            ->subject('Time for Symfony Mailer!')
            ->text('Sending emails is fun again!')
            ->html('<p>See Twig integration for better HTML integration!</p>');

$mailer->send($email);