mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 04:58:46 +02:00
N°7920 - laminas-mail is an abandoned package, replace it with symfony/mailer (#742)
* N°7920 - laminas-mail is an abandoned package, replace it with symfony/mailer * Fix composer following merge
This commit is contained in:
78
lib/symfony/mailer/Transport/Smtp/EsmtpTransportFactory.php
Normal file
78
lib/symfony/mailer/Transport/Smtp/EsmtpTransportFactory.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Mailer\Transport\Smtp;
|
||||
|
||||
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
|
||||
use Symfony\Component\Mailer\Transport\Dsn;
|
||||
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
|
||||
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||
|
||||
/**
|
||||
* @author Konstantin Myakshin <molodchick@gmail.com>
|
||||
*/
|
||||
final class EsmtpTransportFactory extends AbstractTransportFactory
|
||||
{
|
||||
public function create(Dsn $dsn): TransportInterface
|
||||
{
|
||||
$tls = 'smtps' === $dsn->getScheme() ? true : null;
|
||||
$port = $dsn->getPort(0);
|
||||
$host = $dsn->getHost();
|
||||
|
||||
$transport = new EsmtpTransport($host, $port, $tls, $this->dispatcher, $this->logger);
|
||||
|
||||
/** @var SocketStream $stream */
|
||||
$stream = $transport->getStream();
|
||||
$streamOptions = $stream->getStreamOptions();
|
||||
|
||||
if ('' !== $dsn->getOption('verify_peer') && !filter_var($dsn->getOption('verify_peer', true), \FILTER_VALIDATE_BOOL)) {
|
||||
$streamOptions['ssl']['verify_peer'] = false;
|
||||
$streamOptions['ssl']['verify_peer_name'] = false;
|
||||
}
|
||||
|
||||
if (null !== $peerFingerprint = $dsn->getOption('peer_fingerprint')) {
|
||||
$streamOptions['ssl']['peer_fingerprint'] = $peerFingerprint;
|
||||
}
|
||||
|
||||
$stream->setStreamOptions($streamOptions);
|
||||
|
||||
if ($user = $dsn->getUser()) {
|
||||
$transport->setUsername($user);
|
||||
}
|
||||
|
||||
if ($password = $dsn->getPassword()) {
|
||||
$transport->setPassword($password);
|
||||
}
|
||||
|
||||
if (null !== ($localDomain = $dsn->getOption('local_domain'))) {
|
||||
$transport->setLocalDomain($localDomain);
|
||||
}
|
||||
|
||||
if (null !== ($maxPerSecond = $dsn->getOption('max_per_second'))) {
|
||||
$transport->setMaxPerSecond((float) $maxPerSecond);
|
||||
}
|
||||
|
||||
if (null !== ($restartThreshold = $dsn->getOption('restart_threshold'))) {
|
||||
$transport->setRestartThreshold((int) $restartThreshold, (int) $dsn->getOption('restart_threshold_sleep', 0));
|
||||
}
|
||||
|
||||
if (null !== ($pingThreshold = $dsn->getOption('ping_threshold'))) {
|
||||
$transport->setPingThreshold((int) $pingThreshold);
|
||||
}
|
||||
|
||||
return $transport;
|
||||
}
|
||||
|
||||
protected function getSupportedSchemes(): array
|
||||
{
|
||||
return ['smtp', 'smtps'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user