CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

Enabling VPN by Google One causes a 'sendWithSmtp throwed ErrorException'

Open bananacoffee opened this issue 2 years ago • 1 comments

PHP Version

8.2

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MariaDB 10.4.28

What happened?

When attempting to send SMTP emails with VPN by Google One enabled, an error occurred.

Steps to Reproduce

  1. VPN by Google One enabled (Apache Server Exists)
  2. Send SMTP Mail using Email Class

Expected Output

Error

ERROR - 2023-11-14 11:39:35 --> Email: sendWithSmtp throwed ErrorException: Uninitialized string offset 3 in D:\xampp\htdocs\test\vendor\codeigniter4\framework\system\Email\Email.php:2106
Stack trace:
#0 D:\xampp\htdocs\test\vendor\codeigniter4\framework\system\Email\Email.php(2106): CodeIgniter\Debug\Exceptions->errorHandler(2, 'Uninitialized s...', 'D:\\xampp\\htdocs...', 2106)
#1 D:\xampp\htdocs\test\vendor\codeigniter4\framework\system\Email\Email.php(1982): CodeIgniter\Email\Email->getSMTPData()
#2 D:\xampp\htdocs\test\vendor\codeigniter4\framework\system\Email\Email.php(2209): CodeIgniter\Email\Email->sendCommand('quit')
#3 [internal function]: CodeIgniter\Email\Email->__destruct()
#4 {main}

printDebugger

hello: 220 sv10703.xserver.jp ESMTP Postfix
The following SMTP error was encountered: 220 sv1234567.xserver.jp ESMTP Postfix
starttls: 250-sv1234567.xserver.jp
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

The following SMTP error was encountered: 250-sv1234567.xserver.jp
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Unable to send email using SMTP. Your server might not be configured to send mail using this method.

Anything else?

Fixing it to not break on "250 DSN" allowed the email to be sent successfully.

vendor\codeigniter4\framework\system\Email\Email.php
-            if ($str[3] === ' ') {
+            if ($str[3] === ' ' && substr($str, 0, 3) !== '250') {
                break;
            }

printDebugger

hello: 220 sv1234567.xserver.jp ESMTP Postfix
The following SMTP error was encountered: 220 sv1234567.xserver.jp ESMTP Postfix
starttls: 250-sv1234567.xserver.jp
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
220 2.0.0 Ready to start TLS

The following SMTP error was encountered: 250-sv1234567.xserver.jp
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
220 2.0.0 Ready to start TLS

hello: 250-sv1234567.xserver.jp
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

from: 250 2.1.0 Ok
to: 250 2.1.5 Ok
data: 354 End data with <CR><LF>.<CR><LF>
250 2.0.0 Ok: queued as 848D3D02397B63
quit: 221 2.0.0 Bye

bananacoffee avatar Nov 14 '23 03:11 bananacoffee

Thank you for reporting.

But I don't understand why the error occurs.

Uninitialized string offset 3 in D:\xampp\htdocs\test\vendor\codeigniter4\framework\system\Email\Email.php:2106

I'm not sure about the debug logs either. What is "The following SMTP error" ? Can you elaborate?

kenjis avatar Nov 14 '23 23:11 kenjis

This is more than 6 months stale with no response from OP. Closing.

paulbalandan avatar Jul 23 '24 16:07 paulbalandan