下面是我在Drupal中使用plugin.manager.mail发送电子邮件的代码。
$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);我没有使用hook_mail钩子。相反,我在node_presave钩子中调用一个自定义方法来发送电子邮件:
function mymodule_node_presave(EntityInterface $entity) {
if($entity->bundle() == 'events') {
notify_new_events($entity, 'created'); //email piece is detailed within this method
}
}问题:电子邮件不会发送给密件收件人。dd($params)正确显示具有bcc地址的params数组。关于如何解决这个问题有什么帮助吗?!
我正在使用SMTP认证模块发送电子邮件。
发布于 2022-08-05 10:19:52
我得到了一个类似的错误,结果发现一个用户在DB上有一封无效的电子邮件,就像你有"test@test.com“一样。
试着用真正的电子邮件来验证是否是因为这个原因。
我没有看到您的php代码有任何错误。
https://stackoverflow.com/questions/73224735
复制相似问题