Second notification mail is sent to noreply@noreply.com

Created on 28 January 2023, almost 2 years ago
Updated 10 May 2023, over 1 year ago

Since the last update to 8.x-4.0 two instead of one notifications mails are sent. One that I want and another one with the same content to the address noreply@noreply.com which of course cannot be delivered, so I get a response from our mailer daemon.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇩🇪Germany johnnny83

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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.
      
  • Status changed to Fixed over 1 year ago
  • 🇮🇳India manish.upadhyay

    A new release has been released.

  • Status changed to Fixed over 1 year ago
Production build 0.71.5 2024