Skip to content

Commit 66dbcb6

Browse files
committed
minor #13895 Update mailer.rst (ThomasLandauer)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Update mailer.rst Follow-up of symfony/symfony#37313 (comment) Explaining how to "verify" successful delivery by catching the TransportException Commits ------- 939d3cd Update mailer.rst
2 parents b7ef7c5 + 939d3cd commit 66dbcb6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

mailer.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,30 @@ images inside the HTML contents::
279279
->html('<img src="cid:logo"> ... <img src="cid:footer-signature"> ...')
280280
;
281281

282+
Catching Transport Exceptions
283+
-----------------------------
284+
285+
If handing over the email to your transport fails, a
286+
:class:`Symfony\\Component\\Mailer\\Exception\\TransportExceptionInterface` is thrown. To
287+
make sure that sending the email was successful, you can catch that exception::
288+
289+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
290+
291+
$email = new Email();
292+
// ...
293+
try {
294+
$mailer->send($email);
295+
// Display message that email was successfully sent
296+
} catch (TransportExceptionInterface $e) {
297+
// Display message that sending the email failed
298+
}
299+
300+
.. caution::
301+
302+
For Mailer, the sending process was successful, if your transport (SMTP
303+
server or 3rd party provider) accepted the mail for further delivery. This
304+
does not mean that the email has already arrived at the recipient's mail server.
305+
282306
Debugging Emails
283307
----------------
284308

0 commit comments

Comments
 (0)