-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Unable to retrieve SMTP server response error information after EHLO command in SMTP->hello() function #2189
Comments
Well, it does show the issue clearly in debug output, however, suppressing the call to HELO manually is not an appropriate solution, not least because you don't know whether it's going to happen or not – the server could legitimately not support EHLO. Better to detect the 421 error and stop immediately, and not attempt the HELO because of that. That said, RFC5321 says that servers should only respond with 5xx codes for EHLO commands, so I suspect this is a non-standard response, so it's hard to recommend acting on slim evidence. For example, I can connect to gmail like this, just lying about who I am, and get away with it:
|
Good point, I didn't consider the RFCs. The 421 response code is mentioned as a valid EHLO response in RFC1869. This should fix the issue while complying with the RFCs and keeping the fallback functionality in tact:
|
The |
Ignore that last comment – your fix is correct, so I've applied it. Thanks! |
Change inspired by PHPMailer/PHPMailer#2189 RFC 1869 section 4.5 states that the server will return the code 421 if the SMTP server is no longer available This change fixes an issue where the actual error response from a failed EHLO was not surfaced due to always being overridden by the HELLO response.
Problem description
The server receives the EHLO command.
The server rejects the input from the client by responding with a 421 error and breaking the connection.
The hello() function immediately tries to fallback with the HELO command, which fails, because the connection is gone.
The error information from the EHLO response is overwritten with the HELO failure.
Code to reproduce
Debug output
Proposed solution
Add an option to the public function hello to skip the HELO command. By not executing the HELO command you will be able to see the correct error when connecting to mailservers that have this feature enabled.
The text was updated successfully, but these errors were encountered: