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

SMTP.php Failure - FYI #6768

Closed
haxcop opened this issue Jul 26, 2018 · 13 comments
Closed

SMTP.php Failure - FYI #6768

haxcop opened this issue Jul 26, 2018 · 13 comments

Comments

@haxcop
Copy link

haxcop commented Jul 26, 2018

Currently I'm Receiving errors when using the SMTP as Mail Selection into OC 3.0.2.0 with Gmail
BTW no 2SV in place so I do not need an Application Password
I Have contacted my Hosting Provider and it Seems to be Everything in proper working order.

General
Mail Engine SMTP
Mail Parameters
SMTP Hostname tls://smtp.gmail.com
SMTP Username info@domain.com
SMTP Password xxxxxxxxxxxx
SMTP Port 587
SMTP Timeout 5

General
Mail Engine SMTP
Mail Parameters
SMTP Hostname ssl://smtp.gmail.com
SMTP Username info@domain.com
SMTP Password xxxxxxxxxxxx
SMTP Port 465
SMTP Timeout 5

2018-05-11 12:36:36 - PHP Warning: fsockopen(): Failed to enable crypto in /home/user/public_html/domain.com/system/library/mail/smtp.php on line 87 2018-05-11 12:36:36 - PHP Warning: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) in /home/user/public_html/domain.com/system/library/mail/smtp.php on line 87
2018-05-11 12:39:39 - PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /home/user/public_html/domain.com/system/library/mail/smtp.php on line 140

Only Working when choose MAIL with the SMTP authentication details

General
Mail Engine Mail
Mail Parameters
SMTP Hostname tls://smtp.gmail.com
SMTP Username info@domain.com
SMTP Password xxxxxxxxxxxx
SMTP Port 587
SMTP Timeout 5

General
Mail Engine Mail
Mail Parameters
SMTP Hostname ssl://smtp.gmail.com
SMTP Username info@domain.com
SMTP Password xxxxxxxxxxxx
SMTP Port 465
SMTP Timeout 5

@straightlight
Copy link
Contributor

straightlight commented Jul 26, 2018

Interesting. After doing a research on this error message: https://stackoverflow.com/questions/40534135/fockopen-failed-to-enable-crypto , in system/library/mail/smtp.php file,

find:

$handle = fsockopen($hostname, $this->smtp_port, $errno, $errstr, $this->smtp_timeout);

replace with:

$context = stream_context_create(['ssl' => [ 'ciphers' => 'RC4-MD5' ]]);

$handle = stream_socket_client($hostname . ':' . $this->smtp_port, $errno, $errstr, $this->smtp_timeout, STREAM_CLIENT_CONNECT, $context);

See if that solves the issue. However, since you are posting about OC v3.0.2.0 issues, it would of been more appropriate on the forum.

@straightlight
Copy link
Contributor

Followed may also be an important note to consider about this error message: https://stackoverflow.com/questions/5498497/error-with-fsockopen-and-ssl-failed-to-enable-crypto?rq=1

@haxcop
Copy link
Author

haxcop commented Jul 27, 2018

Hi @straightlight Thanks for your time on this info,
I guess was better to post it here as it looks more as a Code Issue than Features to be enabled on our servers, Also I Tested this using OC 2.3.0.2 and the same result.
Reading on the link posted they mentioned it occurs on php56 which I test as well and also currently with php72.

Regarding a Test result on the code you posted
Using : SSL://
2018-05-12 8:07:10 - PHP Warning: stream_socket_client(): unable to connect to ssl://smtp.gmail.com465 (Failed to parse address "smtp.gmail.com465")

Using: TLS://
2018-05-12 8:10:20 - PHP Warning: stream_socket_client(): unable to connect to smtp.gmail.com587 (Failed to parse address "smtp.gmail.com587")

None of these errors on your link ref's are related to this one posted above on my comment.

I will keep the Mail.php for now i guess (it's doing the job at least)

@osworx
Copy link
Contributor

osworx commented Jul 27, 2018

smtp.gmail.com465 or smtp.gmail.com587 will never work.
The port number should not be added to the address directly, you made something wrong (missing : between).

Guess the code should be like:
$handle = stream_socket_client($hostname . ':' . $this->smtp_port, $errno, $errstr, $this->smtp_timeout, STREAM_CLIENT_CONNECT, $context);

@haxcop
Copy link
Author

haxcop commented Jul 27, 2018

@osworx Thanks for your input ; According to your modifications as seen bellow

//$handle = fsockopen($hostname, $this->smtp_port, $errno, $errstr, $this->smtp_timeout); $context = stream_context_create(['ssl' => [ 'ciphers' => 'RC4-MD5' ]]);

//$handle = stream_socket_client($hostname . $this->smtp_port, $errno, $errstr, $this->smtp_timeout, STREAM_CLIENT_CONNECT, $context);
$handle = stream_socket_client($hostname . ':' . $this->smtp_port, $errno, $errstr, $this->smtp_timeout, STREAM_CLIENT_CONNECT, $context);

Here's the error

2018-05-12 8:30:54 - PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in

This will need better time to be tested - I will be out on this weekend so, Won;t be able to keep going on this post until Tuesday...
Will read or do any future modifications if needed.
For now Mail.php I think will be the way

@straightlight
Copy link
Contributor

2018-05-12 8:30:54 - PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in

As you can see, this error message has nothing to do with Opencart since you also claim that the error message also happens when using v2.3.0.2 release while GitHub issues tab is also specifically about the alpha release at this time.

What is happening in this scenario, while I may have forgot to specify the ':' to access the port on my command line above, is that the self-signed certificate fails to be verified with SSL V3 you are using with Gmail authentication. While Opencart is not delivered with Gmail universal solution out-of-the-box, this type of issue still could of been posted on the forum since this error message is a server-related output message result originating from SSL handshake and not caused by Opencart, the following documentation should prove that the connection may fail or succeed when testing the OpenSSL protocol on your server: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting .

Please test the provided command line(s) from the:

Testing SSL outside PHP

section in your SSH console from your host console (or from Putty if allowed). The first line of the output result should either say: CONNECTED or something else. Now, whatever you do, do NOT post the entire results since it includes your SSL certificate begin and end strings. Simply indicate if the first line state that it's CONNECTED or something else.

If it says it's CONNECTED (with the result number), it means it might be a handshake failure from Opencart specifically when using PHP functions due to specific requirements that needs to be set to properly establish the handshake with SSL v3. However, if it provides another message in the output results, it means it's not an OC issue.

@haxcop
Copy link
Author

haxcop commented Aug 8, 2018

Hi @straightlight Here's the output
~]$ echo QUIT | openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 CONNECTED(00000003) depth=1 C = US, O = Google Trust Services, CN = Google Internet Authority G3 verify error:num=20:unable to get local issuer certificate

@straightlight
Copy link
Contributor

Here we go:

Unable to get local issuer certificate

See this solution: https://stackoverflow.com/questions/24372942/ssl-error-unable-to-get-local-issuer-certificate

@haxcop
Copy link
Author

haxcop commented Aug 9, 2018

no working @straightlight - I have even download the cloudflare intermediate certificate (currently using) and keeps Failing.
https://support.cloudflare.com/hc/en-us/articles/115001186052-What-intermediates-and-roots-are-Cloudflare-issued-certs-signed-against-

@kombi747
Copy link

kombi747 commented Aug 9, 2018 via email

@straightlight
Copy link
Contributor

Not an OC bug issue since the returned error message is about the certificate.

@haxcop
Copy link
Author

haxcop commented Aug 10, 2018

@kombi747 I know, but thanks for your concern.
@straightlight It might be the case but, as this thread is quite advance already I will like to finish or close this issue once I got it solved, This might be useful to someone else having the same issue in the future.
I'll post the solution with all the required steps to troubleshoot, once I get it sorted.

@jamesallsup
Copy link
Contributor

Sorry to hear you have an issue, the GiHub bug tracker is not the place to post issues relating to setup, 3rd party modules or general types of questions.

Please read the project information page which should guide you in the right direction for support.

Kind regards, J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants