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;
}