You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a plugin that tracks Sent Emails and attempts to share details with the user about why an email was successful or why it failed. In Craft 2, we had the onSendEmailError event to help out with this info.
In Craft 3, there seem to be several points of failure for email and we're having a hard time getting the specific error message back in many cases. We're currently watching the Yii BaseMailer::EVENT_AFTER_SEND event which does appear to return an error message in place of the $message and provide an $isSuccessful flag:
$event = new MailEvent(['message' => $message, 'isSuccessful' => $isSuccessful]);
However, Craft seems to intercept that response with its own try/catch blocks in different contexts and in several cases we seem to never have a chance to get that response from the Message class back.
We have a plugin that tracks Sent Emails and attempts to share details with the user about why an email was successful or why it failed. In Craft 2, we had the onSendEmailError event to help out with this info.
In Craft 3, there seem to be several points of failure for email and we're having a hard time getting the specific error message back in many cases. We're currently watching the Yii
BaseMailer::EVENT_AFTER_SEND
event which does appear to return an error message in place of the $message and provide an$isSuccessful
flag:However, Craft seems to intercept that response with its own try/catch blocks in different contexts and in several cases we seem to never have a chance to get that response from the Message class back.
If Craft finds a
TemplateLoaderException
, it throws it before the Mailer has a chance to throw an error:https://github.com/craftcms/cms/blob/develop/src/mail/Mailer.php#L144
Craft also throws a different error if it finds a
Swift_TransportException
error:https://github.com/craftcms/cms/blob/develop/src/mail/Mailer.php#L177
In the case of the
TemplateLoaderException
Craft throws an error. In the case of theSwift_TransportException
it just returns false.I'm not sure what the best solution here would be but it would be nice if we could either:
BaseMailer::EVENT_AFTER_SEND
returns predictable results when any error is encounteredEVENT_AFTER_SEND
on thecraft\mail\Mailer
class and refactor any errors to be returned in a consistent wayThe text was updated successfully, but these errors were encountered: