vendor/symfony/mailer/Transport/Smtp/EsmtpTransportFactory.php line 29

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Mailer\Transport\Smtp;
  11. use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
  12. use Symfony\Component\Mailer\Transport\Dsn;
  13. use Symfony\Component\Mailer\Transport\TransportInterface;
  14. /**
  15.  * @author Konstantin Myakshin <molodchick@gmail.com>
  16.  */
  17. final class EsmtpTransportFactory extends AbstractTransportFactory
  18. {
  19.     public function create(Dsn $dsn): TransportInterface
  20.     {
  21.         $tls 'smtps' === $dsn->getScheme() ? true null;
  22.         $port $dsn->getPort(0);
  23.         $host $dsn->getHost();
  24.         $transport = new EsmtpTransport($host$port$tls$this->dispatcher$this->logger);
  25.         if ($user $dsn->getUser()) {
  26.             $transport->setUsername($user);
  27.         }
  28.         if ($password $dsn->getPassword()) {
  29.             $transport->setPassword($password);
  30.         }
  31.         return $transport;
  32.     }
  33.     protected function getSupportedSchemes(): array
  34.     {
  35.         return ['smtp''smtps'];
  36.     }
  37. }