- Issue created by @johnnny83
- 🇸🇰Slovakia Matus Grinvalsky
Actually, this behavior was introduced in version 3.9 and it is because of following chunk of code. Despite the name, the $admin_email holds the list of emails notification should be sent to, not admin email
The list if addresses for notification is populated to bcc and dummy address is used in to fields
// Set a dummy no reply email if email list is not empty. $to = empty($admin_email) ? \Drupal::config('system.site')->get('mail') : 'noreply@noreply.com'; $params = [ 'body' => $body, 'subject' => $subject, 'nid' => $node->id(), ]; // Allow to alter $admin_email // by using hook_admin_content_notification_recipients_alter(). // @see admin_content_notification.api.php \Drupal::moduleHandler() ->alter('admin_content_notification_recipients', $admin_email, $node); if (!empty($admin_email)) { $params['bcc'] = $admin_email; }
I assume that reason for this change is preventing full list of recipients to be disclosed to everyone on a list. In my opinion, it would be better to make the "to" address configurable instead hardcoding it to dummy address.
Sending/receiving bouncing emails is annoying and can potentially trigger some spam rules.
- 🇨🇦Canada alienzed
My client was quite vexed by this, thinking their site was being spammed! I have to undo this change locally. Might I suggest that we should never under any circumstances send emails that we know for sure will fail? I imagine some hosting/email providers who block websites for doing this...
- 🇭🇺Hungary lv46gl
What about this solution?
// Set a dummy no reply email if email list is not empty. $to = empty($admin_email) ? \Drupal::config('system.site')->get('mail') : 'noreply@noreply.com'; $params = [ 'body' => $body, 'subject' => $subject, 'nid' => $node->id(), ]; // Allow to alter $admin_email // by using hook_admin_content_notification_recipients_alter(). // @see admin_content_notification.api.php \Drupal::moduleHandler() ->alter('admin_content_notification_recipients', $admin_email, $node); // delete -> if (!empty($admin_email)) { // delete -> $params['bcc'] = $admin_email; // delete -> } // Allow to alter $params // by using hook_admin_content_notification_params_alter(). // @see admin_content_notification.api.php \Drupal::moduleHandler() ->alter('admin_content_notification_params', $params, $node); if (strlen($admin_email) === 0) { return; } $key = 'admin_content_notification_key'; if (empty($to) || empty(\Drupal::config('system.site')->get('mail'))) { $this->getLogger('admin_content_notification')->error($this->t('From and To email addresses should not be empty.')); return; } foreach (explode(',', $admin_email) as $to) { // <- insert $this->mailManager->mail('admin_content_notification', $key, $to, 'en', $params, \Drupal::config('system.site')->get('mail'), TRUE); } // <- insert
In my case the only email that goes out is to: noreply@noreply.com, from: the admin email address. I have experimented with listing more than one email recipient and with user roles. Same result. None of the listed email accounts receive the email, I just get the mail delivery failed on noreply@noreply.com. This happens with 3.9 and 4.0. I am a site builder with no coding experience and have downgraded to 3.8 for now.
- 🇮🇳India manish.upadhyay
Hi All,
Sorry for the delay in response, I am working on the solution and will be releasing it in next couple of days.
Thanks,
- 62b11032 committed on 8.x-3.x
#3337301: Allow default to address as config.
- 62b11032 committed on 8.x-3.x
- Status changed to Fixed
over 1 year ago 9:14am 10 May 2023 - Status changed to Fixed
over 1 year ago 9:14am 10 May 2023