8000 [Mailer] Add Infobip bridge · symfony/symfony@a0c1d58 · GitHub
[go: up one dir, main page]

Skip to content

Commit a0c1d58

Browse files
[Mailer] Add Infobip bridge
Co-Authored-By: Jean-Baptiste Delhommeau <jeanbadel@gmail.com> Co-Authored-By: Benoit Galati <benoit.galati@gmail.com>
1 parent c70be09 commit a0c1d58

17 files changed

+892
-10
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
2431
Original file line numberDiff line numberDiff line change
@@ -2428,14 +2428,15 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
24282428

24292429
$classToServices = [
24302430
GmailTransportFactory::class => 'mailer.transport_factory.gmail',
+
InfobipTransportFactory::class => 'mailer.transport_factory.infobip',
24312432
MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
24322433
MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
24332434
MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
2435+
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
24342436
PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
24352437
SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
24362438
SendinblueTransportFactory::class => 'mailer.transport_factory.sendinblue',
24372439
SesTransportFactory::class => 'mailer.transport_factory.amazon',
2438-
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
24392440
];
24402441

24412442
foreach ($classToServices as $class => $service) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer_transports.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
1515
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
16+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipTransportFactory;
1617
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
1718
use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
1819
use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
@@ -45,6 +46,10 @@
4546
->parent('mailer.transport_factory.abstract')
4647
->tag('mailer.transport_factory')
4748

49+
->set('mailer.transport_factory.infobip', InfobipTransportFactory::class)
50+
->parent('mailer.transport_factory.abstract')
51+
->tag('mailer.transport_factory')
52+
4853
->set('mailer.transport_factory.mailchimp', MandrillTransportFactory::class)
4954
->parent('mailer.transport_factory.abstract')
5055
->tag('mailer.transport_factory')
@@ -74,8 +79,8 @@
7479
->tag('mailer.transport_factory')
7580

7681
->set('mailer.transport_factory.sendinblue', SendinblueTransportFactory::class)
77-
->parent('mailer.transport_factory.abstract')
78-
->tag('mailer.transport_factory')
82+
->parent('mailer.transport_factory.abstract')
83+
->tag('mailer.transport_factory')
7984

8085
->set('mailer.transport_factory.ohmysmtp', OhMySmtpTransportFactory::class)
8186
->parent('mailer.transport_factory.abstract')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/Tests export-ignore
2+
/phpunit.xml.dist export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/composer.lock
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG
2+
=========
3+
4+
6.1
5+
---
6+
7+
* Add the bridge
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2019-2022 Fabien Potencier
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Infobip Bridge
2+
==============
3+
4+
Provides Infobip integration for Symfony Mailer.
5+
6+
Configuration examples:
7+
8+
```dotenv
9+
# API
10+
MAILER_DSN=infobip+api://KEY@BASE_URL
11+
# SMTP
12+
MAILER_DSN=infobip+smtp://KEY@default
13+
```
14+
15+
Resources
16+
---------
17+
* [Infobip Api Docs](https://www.infobip.com/docs/api#channels/email)
18+
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
19+
* [Report issues](https://github.com/symfony/symfony/issues) and
20+
[send Pull Requests](https://github.com/symfony/symfony/pulls)
21+
in the [main Symfony repository](https://github.com/symfony/symfony)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Symfony package.
7+
*
8+
* (c) Fabien Potencier <fabien@symfony.com>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Symfony\Component\Mailer\Bridge\Infobip\Tests\Transport;
15+
16+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipApiTransport;
17+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipSmtpTransport;
18+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipTransportFactory;
19+
use Symfony\Component\Mailer\Test\TransportFactoryTestCase;
20+
use Symfony\Component\Mailer\Transport\Dsn;
21+
use Symfony\Component\Mailer\Transport\TransportFactoryInterface;
22+
23+
class InfobipApiTransportFactoryTest extends TransportFactoryTestCase
24+
{
25+
public function getFactory(): TransportFactoryInterface
26+
{
27+
return new InfobipTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
28+
}
29+
30+
public function supportsProvider(): iterable
31+
{
32+
yield [
33+
new Dsn('infobip+api', 'default'),
34+
true,
35+
];
36+
37+
yield [
38+
new Dsn('infobip', 'default'),
39+
true,
40+
];
41+
42+
yield [
43+
new Dsn('infobip+smtp', 'default'),
44+
true,
45+
];
46+
47+
yield [
48+
new Dsn('infobip+smtps', 'default'),
49+
true,
50+
];
51+
52+
yield [
53+
new Dsn('infobip+smtp', 'example.com'),
54+
true,
55+
];
56+
}
57+
58+
public function createProvider(): iterable
59+
{
60+
$dispatcher = $this->getDispatcher();
61+
$logger = $this->getLogger();
62+
63+
yield [
64+
new Dsn('infobip+api', 'example.com', self::PASSWORD),
65+
(new InfobipApiTransport(self::PASSWORD, $this->getClient(), $dispatcher, $logger))->setHost('example.com'),
66+
];
67+
68+
yield [
69+
new Dsn('infobip', 'default', self::PASSWORD),
70+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
71+
];
72+
73+
yield [
74+
new Dsn('infobip+smtp', 'default', self::PASSWORD),
75+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
76+
];
77+
78+
yield [
79+
new Dsn('infobip+smtps', 'default', self::PASSWORD),
80+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
81+
];
82+
}
83+
84+
public function unsupportedSchemeProvider(): iterable
85+
{
86+
yield [
87+
new Dsn('infobip+foo', 'infobip', self::USER, self::PASSWORD),
88+
'The "infobip+foo" scheme is not supported; supported schemes for mailer "infobip" are: "infobip", "infobip+api", "infobip+smtp", "infobip+smtps".',
89+
];
90+
}
91+
92+
public function incompleteDsnProvider(): iterable
93+
{
94+
yield [new Dsn('infobip+smtp', 'default')];
95+
yield [new Dsn('infobip+api', 'default')];
96+
yield [new Dsn('infobip+api', 'default', self::PASSWORD)];
97+
}
98+
}

0 commit 31B2 comments

Comments
 (0)
0