From 2f2059a682bbb9d4fc89928a9e516e69df52d385 Mon Sep 17 00:00:00 2001 From: Michael Fox Date: Fri, 10 Apr 2020 12:12:46 -0400 Subject: [PATCH 1/2] Fixes retrieving the swift mail transport from the app container in Laravel 7 --- src/WithMailInterceptor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/WithMailInterceptor.php b/src/WithMailInterceptor.php index d812cd0..7b260af 100644 --- a/src/WithMailInterceptor.php +++ b/src/WithMailInterceptor.php @@ -43,6 +43,11 @@ public function interceptMail() */ public function interceptedMail(): Collection { - return app('swift.transport')->driver()->messages(); + $swiftTransport = (version_compare(app()->version(), '7.0.0', '<')) + ? app('swift.transport') + : (app('mailer')->getSwiftMailer())->getTransport(); + + return $swiftTransport->driver()->messages(); } + } From 7587c63b5ed1aeaa2204a3cc4247f35c0cc6695c Mon Sep 17 00:00:00 2001 From: Michael Fox Date: Fri, 10 Apr 2020 12:20:12 -0400 Subject: [PATCH 2/2] fixes to code-style --- src/WithMailInterceptor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/WithMailInterceptor.php b/src/WithMailInterceptor.php index 7b260af..7c24133 100644 --- a/src/WithMailInterceptor.php +++ b/src/WithMailInterceptor.php @@ -49,5 +49,4 @@ public function interceptedMail(): Collection return $swiftTransport->driver()->messages(); } - }