Fixed SMTP mail not sending using TLS

Status
Not open for further replies.

optrex

Well-known member
Affected version
2.3 Beta 3
  • Symfony\Component\Mailer\Exception\TransportException: Email to from failed: Connection could not be established with host "ssl://smtpserver.au:587": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00010B:SSL routines::wrong version number
  • src/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:154
Above error log created when sending email, no email being received.
 
So, here is what worked for me on Amazon SES on 2.3 Beta 4 in case someone else faces the same problem.

Port: 2465
Encryption: TLS

SSL did not work for me with any port.
 
Tried getting Zeptomail from Zoho to work. Just couldn't. Back to SES for now.

And couldn't get Brevo to work as well. Should be interesting once 2.3 goes stable and a more people use it on their primary forum.
 
Last edited:
Tuesday today. Next RC might be out sometime today. I also need to check if this fixes my issue using 2.3 with Zoho ZeptoMail!
 
  • Symfony\Component\Mailer\Exception\TransportException: Email to from failed: Connection could not be established with host "ssl://smtpserver.au:587": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00010B:SSL routines::wrong version number
  • src/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:154
Above error log created when sending email, no email being received.
Dude, I had the same problem. Some server vendors; Hetzner etc. the main ones. It shuts down 25 ports of all the servers they sell. This is actually for your benefit and the benefit of the server company. With the Xenforo mail system, the IP address where your server is located is included in the spam blacklist. I tried to solve this problem by setting up a mail server with a different IP address, but it did not work because port 25 of that server was closed. I also solved this problem with corporate email.
 
Can the fix be posted here please? I'm running into this issue as well and I'd love to hotfix the files :)
Diff:
Subject: [PATCH] Fixed XF 2.3.0 Release Candidate 3 XF-220652 - Do not force SSL connections when using STARTTLS for SMTP
---
Index: src/XF/Mail/Mailer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Mail/Mailer.php b/src/XF/Mail/Mailer.php
--- a/src/XF/Mail/Mailer.php    (revision ddc8063dcb669172d80f174602806baabaea28db)
+++ b/src/XF/Mail/Mailer.php    (revision f528d6d31ba7b312c605f572b82edffeb526bf60)
@@ -343,15 +343,14 @@
     {
         switch ($type)
         {
-            case 'smtp';
+            case 'smtp':
                 $factory = new EsmtpTransportFactory();
                 return $factory->create(new Dsn(
-                    !empty($config['smtpEncrypt']) && $config['smtpEncrypt'] != 'none' ? 'smtps' : '',
+                    empty($config['smtpEncrypt']) || $config['smtpEncrypt'] !== 'ssl' ? 'smtp' : 'smtps',
                     $config['smtpHost'],
                     $config['smtpLoginUsername'] ?? null,
                     $config['smtpLoginPassword'] ?? null,
-                    $config['smtpPort'] ?? null,
-                    $config
+                    $config['smtpPort'] ?? null
                 ));
 
             case 'file':
 
Diff:
Subject: [PATCH] Fixed XF 2.3.0 Release Candidate 3 XF-220652 - Do not force SSL connections when using STARTTLS for SMTP
---
Index: src/XF/Mail/Mailer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/XF/Mail/Mailer.php b/src/XF/Mail/Mailer.php
--- a/src/XF/Mail/Mailer.php    (revision ddc8063dcb669172d80f174602806baabaea28db)
+++ b/src/XF/Mail/Mailer.php    (revision f528d6d31ba7b312c605f572b82edffeb526bf60)
@@ -343,15 +343,14 @@
     {
         switch ($type)
         {
-            case 'smtp';
+            case 'smtp':
                 $factory = new EsmtpTransportFactory();
                 return $factory->create(new Dsn(
-                    !empty($config['smtpEncrypt']) && $config['smtpEncrypt'] != 'none' ? 'smtps' : '',
+                    empty($config['smtpEncrypt']) || $config['smtpEncrypt'] !== 'ssl' ? 'smtp' : 'smtps',
                     $config['smtpHost'],
                     $config['smtpLoginUsername'] ?? null,
                     $config['smtpLoginPassword'] ?? null,
-                    $config['smtpPort'] ?? null,
-                    $config
+                    $config['smtpPort'] ?? null
                 ));
 
             case 'file':
Can confirm it works, thank you :)

(Now I should go investigate how phpStorm generates diffs, for the next time I want to ~~harass~~ contribute something vs needing to use Beyond Compare 🤔)
 
It's very easy if you have the XF code in a git repo.

You can right click a change or multiple changes in your change list and "Create Patch..." or "Copy as Patch..." or you can right click a commit or a change within a commit and click "Create Patch...".
 
Futurama Bender GIF
 
Status
Not open for further replies.
Back
Top Bottom