Problem/Motivation

In \Drupal\action\Plugin\Action\EmailAction it does the following:

    if ($this->mailManager->mail('system', 'action_send_email', $recipient, $langcode, $params)) {
      $this->logger->notice('Sent email to %recipient', ['%recipient' => $recipient]);
    }
    else {
      $this->logger->error('Unable to send email to %recipient', ['%recipient' => $recipient]);
    }

whereas the docs from \Drupal\Core\Mail\MailManagerInterface::mail() are:

   * @return array
   *   The $message array structure containing all details of the message. If
   *   already sent ($send = TRUE), then the 'result' element will contain the
   *   success indicator of the email, failure being already written to the
   *   watchdog. (Success means nothing more than the message being accepted at
   *   php-level, which still doesn't guarantee it to be delivered.)

Proposed resolution

Remove the error logging as this is already handled and only log a notice if successful. In a way it is a shame that the success logging is not also handled by MailManager - so we have consistent logging of all email sending but that feels like a Drupal 9 type change.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
940 bytes

Here's the fix. Unfortunately it looks like \Drupal\action\Plugin\Action\EmailAction is completely untested.

alexpott’s picture

Here's a test. It wouldn't fail on HEAD but at least it proves that I've broken nothing.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Removing the needs tests tag, this looks solid.

  • catch committed 8494c68 on 8.6.x
    Issue #2933916 by alexpott: EmailAction incorrectly uses the result of...
catch’s picture

Version: 8.6.x-dev » 8.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!

  • catch committed 8f48356 on 8.5.x
    Issue #2933916 by alexpott: EmailAction incorrectly uses the result of...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.