【发布时间】:2021-09-14 00:05:06
【问题描述】:
随着我的应用程序不断发展,我需要向大量用户发送电子邮件的正确方式。目前我们的交易电子邮件运作良好,这就是它们的结构。
.env 文件:
###> symfony/postmark-mailer ###
MAILER_DSN=postmark://token@default
###< symfony/postmark-mailer ###
发送电子邮件的控制器:
$email = (new Email())
->from('emailaddress', 'Sitename')
->to($email)
->priority(Email::PRIORITY_HIGH)
->subject('Subject line here')
->text("Your account's email has been changed to this one. If you didn't do this, contact us.");
//Send it.
$mailer->send($email);
这可行,但是当我们要批量发送电子邮件(广播)时,这不起作用。我们尝试通过这样做来更改标题:
$email = (new TemplatedEmail())
->from(new Address('emailaddress', 'Sitename'))
->subject('Subject line')
->htmlTemplate('email/post.html.twig')
->context([
'postTitle' => $post_title,
'postContent' => $post_content_updated,
'profilePicture' => $user->getProfilePicture(),
'displayName' => $user->getDisplayName(),
]);
foreach($subscribers as $subscriber)
{
$email->addBcc($subscriber->getEmail());
}
$email->getHeaders()
->addTextHeader('X-PM-Message-Stream', 'broadcast');
$mailer->send($email);
我们得到一个错误:ErrorCode: '300', Message: 'Maximum of 50 recipients allowed per email message'.
我注意到此错误显示在默认事务流而不是广播中。我们如何进行这项工作?我似乎找不到与此相关的文档。
【问题讨论】: