Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: The error occurred when the built-in Email library was forced to switch to TLS while setting port 465 #7520

Closed
skycyclone opened this issue May 24, 2023 · 4 comments · Fixed by #7883
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author

Comments

@skycyclone
Copy link

skycyclone commented May 24, 2023

PHP Version

8.1

CodeIgniter4 Version

4.3.4

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

No response

What happened?

The built-in Email library, when specifying the SMTP port as 465, disregards the SMTPCrypto settings, and directly sets the encryption method as tls://, which is incomprehensible to me.

Many email services provide SMTP SSL ports that are designated as 465, but the protocols they offer may only be one of ssl:// and tls://, or one may be stable while the other is not. This choice should ideally be decided by the user.

My current situation is that in Codeigniter3, the smtp_crypto was set to ssl on port 465 and has been running stably. But after upgrading the system to Codeigniter4, I found that the framework forcibly sets tls:// when setting port 465; causing the email failure rate to be as high as 30%.

For now, there's no solution, so I had to temporarily set it to port 25 without specifying SMTPCrypto, and no errors have occurred so far. In the old system, the same SMTP parameters of 465+SSL combination also never caused errors.

The SMTP service I use is from 126.com's email service, and the SMTP server address is smtp.126.com.

Steps to Reproduce

$config['protocol'] = 'smtp';
$config['SMTPHost'] = 'smtp.126.com';
$config['SMTPPort'] = 465;
$config['SMTPCrypto'] = 'ssl';
$config['SMTPUser'] = '***';
$config['SMTPPass'] = '***';

$email->initialize($config);

$email->setFrom('your@example.com', 'Your Name');
$email->setTo('someone@example.com');
$email->setSubject('Email Test');
$email->setMessage('Testing the email class.');

$email->send();

Expected Output

To send emails steadily and normally.

Anything else?

No response

@skycyclone skycyclone added the bug Verified issues on the current code behavior or pull requests that will fix them label May 24, 2023
@kenjis
Copy link
Member

kenjis commented May 25, 2023

My current situation is that in Codeigniter3, the smtp_crypto was set to ssl on port 465 and has been running stably. But after upgrading the system to Codeigniter4, I found that the framework forcibly sets tls:// when setting port 465; causing the email failure rate to be as high as 30%.

I don't understand why the failure rate is as high as 30%.

@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label May 27, 2023
@kenjis
Copy link
Member

kenjis commented May 27, 2023

This is not a bug, but a bug fix: #3430
Please ask the service provider why tls makes unstable.

@kenjis kenjis added the waiting for info Issues or pull requests that need further clarification from the author label May 27, 2023
@kenjis kenjis changed the title Bug: The error occurred when the built-in Email library was forced to switch to TSL while setting port 465 Bug: The error occurred when the built-in Email library was forced to switch to TLS while setting port 465 Jun 4, 2023
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 22, 2023
@kenjis
Copy link
Member

kenjis commented Aug 22, 2023

It would be unlike CI to force the library to change user's settings.
I would like to fix this behavior as a bug.
See also #7522 (comment)

@kenjis
Copy link
Member

kenjis commented Aug 30, 2023

@skycyclone I sent a PR to fix this: #7883
Try if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author
Projects
None yet
2 participants