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

Skip to content

Commit 1f9c282

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 5bc5827 commit 1f9c282

17 files changed

+874
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,7 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
24312431

24322432
$classToServices = [
24332433
GmailTransportFactory::class => 'mailer.transport_factory.gmail',
2434+
InfobipTransportFactory::class => 'mailer.transport_factory.infobip',
24342435
MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
24352436
MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
24362437
MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',

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.2
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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Mailer\Bridge\Infobip\Tests\Transport;
13+
14+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipApiTransport;
15+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipSmtpTransport;
16+
use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipTransportFactory;
17+
use Symfony\Component\Mailer\Test\TransportFactoryTestCase;
18+
use Symfony\Component\Mailer\Transport\Dsn;
19+
use Symfony\Component\Mailer\Transport\TransportFactoryInterface;
20+
21+
class InfobipApiTransportFactoryTest extends TransportFactoryTestCase
22+
{
23+
public function getFactory(): TransportFactoryInterface
24+
{
25+
return new InfobipTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
26+
}
27+
28+
public function supportsProvider(): iterable
29+
{
30+
yield [
31+
new Dsn('infobip+api', 'default'),
32+
true,
33+
];
34+
35+
yield [
36+
new Dsn('infobip', 'default'),
37+
true,
38+
];
39+
40+
yield [
41+
new Dsn('infobip+smtp', 'default'),
42+
true,
43+
];
44+
45+
yield [
46+
new Dsn('infobip+smtps', 'default'),
47+
true,
48+
];
49+
50+
yield [
51+
new Dsn('infobip+smtp', 'example.com'),
52+
true,
53+
];
54+
}
55+
56+
public function createProvider(): iterable
57+
{
58+
$dispatcher = $this->getDispatcher();
59+
$logger = $this->getLogger();
60+
61+
yield [
62+
new Dsn('infobip+api', 'example.com', self::PASSWORD),
63+
(new InfobipApiTransport(self::PASSWORD, $this->getClient(), $dispatcher, $logger))->setHost('example.com'),
64+
];
65+
66+
yield [
67+
new Dsn('infobip', 'default', self::PASSWORD),
68+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
69+
];
70+
71+
yield [
72+
new Dsn('infobip+smtp', 'default', self::PASSWORD),
73+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
74+
];
75+
76+
yield [
77+
new Dsn('infobip+smtps', 'default', self::PASSWORD),
78+
new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger),
79+
];
80+
}
81+
82+
public function unsupportedSchemeProvider(): iterable
83+
{
84+
yield [
85+
new Dsn('infobip+foo', 'infobip', self::USER, self::PASSWORD),
86+
'The "infobip+foo" scheme is not supported; supported schemes for mailer "infobip" are: "infobip", "infobip+api", "infobip+smtp", "infobip+smtps".',
87+
];
88+
}
89+
90+
public function incompleteDsnProvider(): iterable
91+
{
92+
yield [new Dsn('infobip+smtp', 'default')];
93+
yield [new Dsn('infobip+api', 'default')];
94+
yield [new Dsn('infobip+api', 'default', self::PASSWORD)];
95+
}
96+
}

0 commit comments

Comments
 (0)
0