File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 12
12
use Illuminate \Mail \Transport \SesTransport ;
13
13
use Illuminate \Mail \Transport \SesV2Transport ;
14
14
use Illuminate \Support \Arr ;
15
+ use Illuminate \Support \ConfigurationUrlParser ;
15
16
use Illuminate \Support \Str ;
16
17
use InvalidArgumentException ;
17
18
use Psr \Log \LoggerInterface ;
@@ -446,9 +447,17 @@ protected function getConfig(string $name)
446
447
// Here we will check if the "driver" key exists and if it does we will use
447
448
// the entire mail configuration file as the "driver" config in order to
448
449
// provide "BC" for any Laravel <= 6.x style mail configuration files.
449
- return $ this ->app ['config ' ]['mail.driver ' ]
450
+ $ config = $ this ->app ['config ' ]['mail.driver ' ]
450
451
? $ this ->app ['config ' ]['mail ' ]
451
452
: $ this ->app ['config ' ]["mail.mailers. {$ name }" ];
453
+
454
+ if (isset ($ config ['url ' ])) {
455
+ $ config = array_merge ($ config , (new ConfigurationUrlParser )->parseConfiguration ($ config ));
456
+
457
+ $ config ['transport ' ] = Arr::pull ($ config , 'driver ' );
458
+ }
459
+
460
+ return $ config ;
452
461
}
453
462
454
463
/**
Original file line number Diff line number Diff line change 4
4
5
5
use InvalidArgumentException ;
6
6
use Orchestra \Testbench \TestCase ;
7
+ use Symfony \Component \Mailer \Transport \Smtp \EsmtpTransport ;
7
8
8
9
class MailManagerTest extends TestCase
9
10
{
@@ -27,6 +28,22 @@ public function testEmptyTransportConfig($transport)
27
28
$ this ->app ['mail.manager ' ]->mailer ('custom_smtp ' );
28
29
}
29
30
31
+ public function testMailUrlConfig ()
32
+ {
33
+ $ this ->app ['config ' ]->set ('mail.mailers.smtp_url ' , [
34
+ 'url ' =>
'smtp://usr:[email protected] :5876 ' ,
35
+ ]);
36
+
37
+ $ mailer = $ this ->app ['mail.manager ' ]->mailer ('smtp_url ' );
38
+ $ transport = $ mailer ->getSymfonyTransport ();
39
+
40
+ $ this ->assertInstanceOf (EsmtpTransport::class, $ transport );
41
+ $ this ->assertSame ('usr ' , $ transport ->getUsername ());
42
+ $ this ->assertSame ('pwd ' , $ transport ->getPassword ());
43
+ $ this ->assertSame ('127.0.0.2 ' , $ transport ->getStream ()->getHost ());
44
+ $ this ->assertSame (5876 , $ transport ->getStream ()->getPort ());
45
+ }
46
+
30
47
public static function emptyTransportConfigDataProvider ()
31
48
{
32
49
return [
You can’t perform that action at this time.
0 commit comments