Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#3 | 2933916-3.patch | 2.97 KB | alexpott |
#3 | 2-3-interdiff.txt | 2.05 KB | alexpott |
#2 | 2933916-2.patch | 940 bytes | alexpott |
Comments
Comment #2
alexpottHere's the fix. Unfortunately it looks like
\Drupal\action\Plugin\Action\EmailAction
is completely untested.Comment #3
alexpottHere's a test. It wouldn't fail on HEAD but at least it proves that I've broken nothing.
Comment #5
borisson_Removing the needs tests tag, this looks solid.
Comment #7
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!