Commit 9e2f59b4 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout d'une garde pour attraper les exceptions lors de l'envoi des mails

parent 1bfe158d
Loading
Loading
Loading
Loading
Loading
+43 −41
Original line number Diff line number Diff line
@@ -273,6 +273,8 @@ EOS;
            $to = implode(',', $to);
        }

        try {

            /** @var Mail $mail */
            $mail = $this->createMailEntity();
            $mail->setDateEnvoi(new DateTime());
@@ -310,19 +312,19 @@ EOS;
                        $mailSymfony = $this->prepareMessageForRedirection($mailSymfony, $module);
                    }
                    $this->getMailer()->send($mailSymfony);
            }
            catch (TransportExceptionInterface $e) {
                } catch (TransportExceptionInterface $e) {
                    throw new RuntimeException("Échec de l'envoi du message", 0, $e);
                }

                $mail->setStatusEnvoi(Mail::SUCCESS);
        }
        else {
            } else {
                $mail->setStatusEnvoi(Mail::NOTSENT);
            }

            $this->update($mail);

        } catch (Exception) {
            return null;
        }
        return $mail;
    }