简体   繁体   English

密件抄送电子邮件未送达 - Drupal 9 SMTP

[英]bcc emails are not delivered - Drupal 9 SMTP

Below is my code to send out email using plugin.manager.mail in Drupal.下面是我在 Drupal 中使用plugin.manager.mail发送 email 的代码。

$params['context']['subject'] = t('[@site] A new event has been created');
$params['context']['message'] = $mode_info . '' .
                                'Hello User !' . '<br />' .
                                '<p class="notif-email">'.'A new event has been added to the PREP website. Below are the details of the new event: '. '<br />' .
                                'Event details: '.$event_details;
$s_recipients = implode(', ', $event_recipients);
$to = 'test@test.com';
$params['headers']['bcc'] = $s_recipients;
\Drupal::service('plugin.manager.mail')->mail('system', 'mail', $to, $langcode, $params);

I am not using hook_mail hook.我没有使用 hook_mail 钩子。 rather, I call a custom method within node_presave hook to send out the email:相反,我调用 node_presave 挂钩中的自定义方法来发送 email:

function mymodule_node_presave(EntityInterface $entity) {
  if($entity->bundle() == 'events') {
    notify_new_events($entity, 'created'); //email piece is detailed within this method
  }
}

Problem: Email is not sent out for bcc recipients.问题:没有为密件抄送收件人发送 Email。 doing dd($params) shows params array with bcc addresses correctly.做 dd($params) 正确显示带有密件抄送地址的 params 数组。 Any help on how this can be fixed pls?!关于如何解决这个问题的任何帮助?

I am using SMTP authentication module to send out the emails.我正在使用 SMTP 身份验证模块发送电子邮件。

I got a similar error and turns out a user had an invalid email on DB, like you have "test@test.com".我遇到了类似的错误,结果发现用户在 DB 上有一个无效的 email,就像你有“test@test.com”一样。

Try to use real emails to validate if it is because of that or not.尝试使用真实的电子邮件来验证是否是因为这个。

I am not seeing any error on your php code.我在您的 php 代码上没有看到任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM