I have a project in which several emails are sent in certain situations. The mail service used is sendgrid and sometimes it gives an exception, which prevents the rest of the code after sending the email from executing. Do I have to wrap every Mail::send into a try catch block?
Mail::send('view', [
'variable' => $variable
], function ($message) use ($address, $variable) {
$message->to($address)
->subject("Subject");
});
I looked at Mailer.php where the send() method is defined and I saw that it calls this method
return $this->sendSwiftMessage($message);
which looks like this
protected function sendSwiftMessage($message)
{
if ($this->events) {
$this->events->fire(new EventsMessageSending($message));
}
try {
return $this->swift->send($message, $this->failedRecipients);
} finally {
$this->swift->getTransport()->stop();
}
}
Does it crash because it does not have a catch block? Why doesn't it?
question from:
https://stackoverflow.com/questions/65651719/why-does-laravel-sending-mail-method-not-have-a-try-catch 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…