Skip to content

Commit bd5f55d

Browse files
committed
Migrate Mailgun transport
1 parent 43364ea commit bd5f55d

File tree

4 files changed

+22
-241
lines changed

4 files changed

+22
-241
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"pda/pheanstalk": "^4.0",
9191
"phpunit/phpunit": "^9.4",
9292
"predis/predis": "^1.1.2",
93-
"symfony/cache": "^6.0"
93+
"symfony/cache": "^6.0",
94+
"symfony/mailgun-mailer": "^6.0"
9495
},
9596
"provide": {
9697
"psr/container-implementation": "1.0"
@@ -153,6 +154,8 @@
153154
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^5.0|^6.0).",
154155
"symfony/cache": "Required to PSR-6 cache bridge (^6.0).",
155156
"symfony/filesystem": "Required to enable support for relative symbolic links (^6.0).",
157+
"symfony/http-client": "Required to enable support for the Mailgun mail driver when using the https or api scheme (^6.0).",
158+
"symfony/mailgun-mailer": "Required to enable support for the Mailgun mail driver (^6.0).",
156159
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
157160
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
158161
},

src/Illuminate/Mail/MailManager.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
use Aws\SesV2\SesV2Client;
66
use Closure;
7-
use GuzzleHttp\Client as HttpClient;
87
use Illuminate\Contracts\Mail\Factory as FactoryContract;
98
use Illuminate\Log\LogManager;
109
use Illuminate\Mail\Transport\ArrayTransport;
1110
use Illuminate\Mail\Transport\LogTransport;
12-
use Illuminate\Mail\Transport\MailgunTransport;
1311
use Illuminate\Mail\Transport\SesTransport;
1412
use Illuminate\Support\Arr;
1513
use Illuminate\Support\Str;
1614
use InvalidArgumentException;
1715
use Postmark\Transport as PostmarkTransport;
1816
use Psr\Log\LoggerInterface;
17+
use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
18+
use Symfony\Component\Mailer\Transport\Dsn;
1919
use Symfony\Component\Mailer\Transport\FailoverTransport;
2020
use Symfony\Component\Mailer\Transport\SendmailTransport;
2121
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
@@ -280,20 +280,28 @@ protected function createMailTransport()
280280
* Create an instance of the Mailgun Swift Transport driver.
281281
*
282282
* @param array $config
283-
* @return \Illuminate\Mail\Transport\MailgunTransport
283+
* @return \Symfony\Component\Mailer\Transport\TransportInterface
284284
*/
285285
protected function createMailgunTransport(array $config)
286286
{
287+
$factory = new MailgunTransportFactory();
288+
289+
if (isset($config['dsn'])) {
290+
return $factory->create(
291+
Dsn::fromString($config['dsn'])
292+
);
293+
}
294+
287295
if (! isset($config['secret'])) {
288296
$config = $this->app['config']->get('services.mailgun', []);
289297
}
290298

291-
return new MailgunTransport(
292-
$this->guzzle($config),
299+
return $factory->create(new Dsn(
300+
'mailgun+api',
301+
$config['endpoint'] ?? 'default',
293302
$config['secret'],
294-
$config['domain'],
295-
$config['endpoint'] ?? null
296-
);
303+
$config['domain']
304+
));
297305
}
298306

299307
/**
@@ -371,21 +379,6 @@ protected function createArrayTransport()
371379
return new ArrayTransport;
372380
}
373381

374-
/**
375-
* Get a fresh Guzzle HTTP client instance.
376-
*
377-
* @param array $config
378-
* @return \GuzzleHttp\Client
379-
*/
380-
protected function guzzle(array $config)
381-
{
382-
return new HttpClient(Arr::add(
383-
$config['guzzle'] ?? [],
384-
'connect_timeout',
385-
60
386-
));
387-
}
388-
389382
/**
390383
* Set a global address on the mailer by type.
391384
*

src/Illuminate/Mail/Transport/MailgunTransport.php

Lines changed: 0 additions & 216 deletions
This file was deleted.

src/Illuminate/Mail/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
},
3939
"suggest": {
4040
"aws/aws-sdk-php": "Required to use the SES mail driver (^3.189.0).",
41-
"guzzlehttp/guzzle": "Required to use the Mailgun mail driver (^7.2).",
41+
"symfony/http-client": "Required to use the Mailgun mail driver (^6.0).",
42+
"symfony/mailgun-mailer": "Required to enable support for the Mailgun mail driver (^6.0).",
4243
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
4344
},
4445
"config": {

0 commit comments

Comments
 (0)