Prior to using Queue Mail, I was sending an email using custom code like this:

$result = $mailer->mail($module, $key, $to, $language, $params, NULL, $send);
if ($result['result'] !== TRUE) {
  // Report error.
}
  else {
  // Report success.
}

When using Queue Mail, $send is set to FALSE, so $result['result'] doesn't get returned as TRUE. This makes it appear that the process failed. It would be helpful if there were a return value to indicate that the message was successfully queued.

Patch to follow.

CommentFileSizeAuthor
#2 3039506-2.add-return-value.patch566 bytesjrb

Comments

jrb created an issue. See original summary.

jrb’s picture

Status: Active » Needs review
StatusFileSize
new566 bytes

Attached patch adds a boolean $result['queued'] to the array returned by the call to \Drupal::service('plugin.manager.mail')->mail() so you can have code like this:

$result = $mailer->mail($module, $key, $to, $language, $params, NULL, $send);
if ($result['queued'] !== TRUE) {
  // Report error.
}
  else {
  // Report success.
}
jrb’s picture

Title: Return value to indicate that mail was successfully queued » Provide return value to indicate that mail was successfully queued

  • sinn committed d621bf3 on 8.x-1.x
    #3039506. Provide return value to indicate that mail was successfully...
sokru’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

sinn’s picture

Assigned: Unassigned » sinn
Status: Closed (fixed) » Needs work
sinn’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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