File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 15
15
use Symfony \Component \EventDispatcher \Event ;
16
16
use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
17
17
use Symfony \Component \Mailer \Event \MessageEvent ;
18
+ use Symfony \Component \Mailer \Exception \TransportExceptionInterface ;
18
19
use Symfony \Component \Mailer \Messenger \SendEmailMessage ;
19
20
use Symfony \Component \Mailer \Transport \TransportInterface ;
21
+ use Symfony \Component \Messenger \Exception \HandlerFailedException ;
20
22
use Symfony \Component \Messenger \MessageBusInterface ;
21
23
use Symfony \Component \Mime \RawMessage ;
22
24
use Symfony \Contracts \EventDispatcher \EventDispatcherInterface as SymfonyEventDispatcherInterface ;
@@ -52,6 +54,15 @@ public function send(RawMessage $message, Envelope $envelope = null): void
52
54
$ this ->dispatcher ->dispatch ($ event );
53
55
}
54
56
55
- $ this ->bus ->dispatch (new SendEmailMessage ($ message , $ envelope ));
57
+ try {
58
+ $ this ->bus ->dispatch (new SendEmailMessage ($ message , $ envelope ));
59
+ } catch (HandlerFailedException $ e ) {
60
+ foreach ($ e ->getNestedExceptions () as $ nested ) {
61
+ if ($ nested instanceof TransportExceptionInterface) {
62
+ throw $ nested ;
63
+ }
64
+ }
65
+ throw $ e ;
66
+ }
56
67
}
57
68
}
You can’t perform that action at this time.
0 commit comments