|
| 1 | +diff --git a/vendor/magento/module-email/Model/Transport.php b/vendor/magento/module-email/Model/Transport.php |
| 2 | +index b46e4564e327f..02631e9564c2a 100644 |
| 3 | +--- a/vendor/magento/module-email/Model/Transport.php |
| 4 | ++++ b/vendor/magento/module-email/Model/Transport.php |
| 5 | +@@ -16,6 +16,7 @@ |
| 6 | + use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; |
| 7 | + use Symfony\Component\Mailer\Transport\Smtp\Auth\LoginAuthenticator; |
| 8 | + use Symfony\Component\Mailer\Transport\Smtp\Auth\PlainAuthenticator; |
| 9 | ++use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransportFactory; |
| 10 | + use Magento\Framework\App\Config\ScopeConfigInterface; |
| 11 | + use Magento\Framework\App\ObjectManager; |
| 12 | + use Magento\Framework\Exception\MailException; |
| 13 | +@@ -78,6 +79,11 @@ class Transport implements TransportInterface |
| 14 | + */ |
| 15 | + private const XML_PATH_SSL = 'system/smtp/ssl'; |
| 16 | + |
| 17 | ++ /** |
| 18 | ++ * SMTP scheme constant |
| 19 | ++ */ |
| 20 | ++ private const SMTP_SCHEME = 'smtp'; |
| 21 | ++ |
| 22 | + /** |
| 23 | + * Whether return path should be set or no. |
| 24 | + * |
| 25 | +@@ -146,7 +152,7 @@ public function __construct( |
| 26 | + public function getTransport(): SymfonyTransportInterface |
| 27 | + { |
| 28 | + if (!isset($this->symfonyTransport)) { |
| 29 | +- $transportType = $this->scopeConfig->getValue(self::XML_PATH_TRANSPORT); |
| 30 | ++ $transportType = $this->scopeConfig->getValue(self::XML_PATH_TRANSPORT, ScopeInterface::SCOPE_STORE); |
| 31 | + if ($transportType === 'smtp') { |
| 32 | + $this->symfonyTransport = $this->createSmtpTransport(); |
| 33 | + } else { |
| 34 | +@@ -170,19 +176,27 @@ private function createSmtpTransport(): SymfonyTransportInterface |
| 35 | + $password = $this->scopeConfig->getValue(self::XML_PATH_PASSWORD, ScopeInterface::SCOPE_STORE); |
| 36 | + $auth = $this->scopeConfig->getValue(self::XML_PATH_AUTH, ScopeInterface::SCOPE_STORE); |
| 37 | + $ssl = $this->scopeConfig->getValue(self::XML_PATH_SSL, ScopeInterface::SCOPE_STORE); |
| 38 | +- $tls = false; |
| 39 | + |
| 40 | ++ $options = []; |
| 41 | + if ($ssl === 'tls') { |
| 42 | +- $tls = true; |
| 43 | ++ $options['tls'] = true; |
| 44 | ++ } elseif ($ssl === 'ssl') { |
| 45 | ++ $options['ssl'] = true; |
| 46 | ++ $options['verify_peer'] = true; |
| 47 | ++ $options['verify_peer_name'] = true; |
| 48 | + } |
| 49 | + |
| 50 | +- $transport = new EsmtpTransport($host, $port, $tls); |
| 51 | +- if ($username) { |
| 52 | +- $transport->setUsername($username); |
| 53 | +- } |
| 54 | +- if ($password) { |
| 55 | +- $transport->setPassword($password); |
| 56 | +- } |
| 57 | ++ $dsn = new Dsn( |
| 58 | ++ self::SMTP_SCHEME, |
| 59 | ++ $host, |
| 60 | ++ $username, |
| 61 | ++ $password, |
| 62 | ++ $port, |
| 63 | ++ $options |
| 64 | ++ ); |
| 65 | ++ |
| 66 | ++ $factory = new EsmtpTransportFactory(); |
| 67 | ++ $transport = $factory->create($dsn); |
| 68 | + |
| 69 | + switch ($auth) { |
| 70 | + case 'plain': |
0 commit comments