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

Could not open socket #30

Closed
bfsmith07 opened this issue Nov 12, 2016 · 28 comments
Closed

Could not open socket #30

bfsmith07 opened this issue Nov 12, 2016 · 28 comments

Comments

@bfsmith07
Copy link

bfsmith07 commented Nov 12, 2016

I have tried both SSL and TLS.
I have tried both smtp.gmail.com and smtp.googlemail.com
I have tried enabling "Allow less secure apps" in my gmail account

I am using this on a Fedora 24 box, fully updated.
PHP version 5.6.27
ZEND engine 2.6.0
Magento 2.1.2

Nothing seems to work, always get the same error "Could not open socket". Am I missing something? Please let me know if there's something else I should try to get this working.

Thanks.

@srenon
Copy link
Contributor

srenon commented Nov 13, 2016

@bfsmith07 ... check to see if you port is open .... see #24

@bfsmith07
Copy link
Author

telnet smtp.gmail.com 465
Trying 2607:f8b0:4001:c15::6c...
Connected to smtp.gmail.com.
Escape character is '^]'.
Connection closed by foreign host.

@srenon
Copy link
Contributor

srenon commented Nov 13, 2016

@hubaig
Copy link

hubaig commented Nov 15, 2016

Hi,

I have the same problem. I have Open SSL installed and enabled.

$ telnet smtp.gmail.com 465
Trying 74.125.193.108...
Connected to smtp.gmail.com.
Escape character is '^]'.

OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1e-fips 11 Feb 2013
OpenSSL Header Version OpenSSL 1.0.1e-fips 11 Feb 2013
Openssl default config /etc/pki/tls/openssl.cnf

Is there any way I can find out what is causing this?

Regards,
Hussain

@srenon
Copy link
Contributor

srenon commented Nov 15, 2016

What does php -r "mail('s@gmail.com', 'My Subject', 'test');" return

@hubaig
Copy link

hubaig commented Nov 15, 2016

That does not return anything and I get the email in my spam folder.

@coresh
Copy link

coresh commented Nov 23, 2016

Helped for me: solution for smtp servers (including gmail):

$ php --version
PHP 7.0.13 (cli) (built: Nov  8 2016 20:41:42) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

vendor/magento/zendframework1/library/Zend/Mail/Protocol/Abstract.php function _connect($remote)
remove '@' at line: 267 like an example:

// $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);
$this->_socket = stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);

for self-signed SSL certificates:
comment line: 267 and add additional code like an example:

// $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);
        $ctx = stream_context_create(['ssl' => [
            'verify_peer'      => false,
            'verify_peer_name' => false
        ]]);
        $this->_socket = stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION, STREAM_CLIENT_CONNECT, $ctx);

vendor/magepal/magento2-gmailsmtpapp/Controller/Adminhtml/Test/Index.php:73
for chrome/chromium browsers,
during 'Sending test email', force email password like an example:
// 'password' => $password,
'password' => 'your email password',

@hubaig
Copy link

hubaig commented Nov 24, 2016

Can you please explain in detail how you fixed this issue?

@coresh
Copy link

coresh commented Nov 24, 2016

@hubaig : Additional details added to previous comment. Is the current statement: pretty clear and understandable?

@kodeakpaul
Copy link

kodeakpaul commented Dec 11, 2016

I have the same issue:
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1e-fips 11 Feb 2013
OpenSSL Header Version OpenSSL 1.0.1e-fips 11 Feb 2013
Openssl default config /etc/pki/tls/openssl.cnf

Telnet works, I have other 1.x Magento's on the same server using ASchroder Gmail SMTP extension, that works fine. Trying to find a solution for 2.x

I tried @coresh solution and that does nothing. Coresh you should update your comment to have a better location: vendor/magento/zendframework1/library/Zend/Mail/Protocol/Abstract.php:267

I get this error with TLS:
Warning: stream_socket_enable_crypto(): Peer certificate CN=*.server.com' did not match expected CN=smtp.gmail.com' in /public_html/sandbox/vendor/magento/zendframework1/library/Zend/Mail/Protocol/Smtp.php on line 206

Help!

@coresh
Copy link

coresh commented Dec 11, 2016

@Truxxx : comment - updated. Solution worked for me. Please try again attentively

@kodeakpaul
Copy link

kodeakpaul commented Dec 13, 2016

@coresh Thanks, I missed the ctx, however now i'm getting the error: "Incorrect authentication data " and I know my credentials are correct. I have also tried using different gmail and google apps accounts.

@coresh
Copy link

coresh commented Dec 13, 2016

Try manually fix for testing purpose using browser (only for testing by browser)
Why? - Browser not correct updated input field:

vendor/magepal/magento2-gmailsmtpapp/Controller/Adminhtml/Test/Index.php:73
for chrome/chromium browsers,
during 'Sending test email', force email password like an example:
// 'password' => $password,
'password' => 'your email password',

For production usage should be: 'password' => $password,

@kodeakpaul
Copy link

@coresh before I even posted I tried different browsers, I also tried setting the username and password
manually in vendor/magepal/magento2-gmailsmtpapp/Controller/Adminhtml/Test/Index.php:73

First I just tried the password per your instructions, but then I tried the username as well. It always comes back with the same error, I tried different Gmail/Google Apps accounts as well.

@kodeakpaul
Copy link

Is there some sort of error log I can check?

@coresh
Copy link

coresh commented Dec 19, 2016

@Truxxx could you check another smtp server (e.g: your own smtp server) instead of the google smtp server and trace smtp log (tail -n 1000 /var/log/maillog and etc... on the smtp server side)?

@kodeakpaul
Copy link

@coresh Thanks for the response!
I have removed this plugin and reinstalled it with composer.

Have your suggested edits be committed? I didn't need to change anything it already had the code when I looked at it.

Anyways I have tried with another SMTP host, bluehost, bluehost will allow me to send SSL or NON SSL however I get the same error with SSL: "Incorrect authentication data"

Without SSL I get this error:
Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in public_html/sandbox/vendor/magento/zendframework1/library/Zend/Mail/Protocol/Abstract.php on line 272

I haven't had a chance to try it on the SMTP server that's on the local server itself, its not enabled by default and I have to change somethings around before and set it up before I can test it that way.

@srenon
Copy link
Contributor

srenon commented Dec 29, 2016

@coresh
Copy link

coresh commented Dec 31, 2016

@Truxxx, could you try again with php 7.*?

my current php version:

$ php -v
PHP 7.0.14 (cli) (built: Dec  7 2016 10:01:29) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

@pmagony
Copy link

pmagony commented Jan 11, 2017

The description states this can be used with "Other" SMTP. I'm trying to leverage GoDaddy smtp. Is this possible? I'm getting timeout requests on my efforts.

@srenon
Copy link
Contributor

srenon commented Jan 11, 2017

@pmagony ... Can you provide the exact error message you are getting?

@pmagony
Copy link

pmagony commented Jan 11, 2017

@srenon sure, I've tried several configurations, using a Gmail account and Gmail settings, as well as GoDaddy settings and in both cases I've received the following error:

Result: Connection timed out

Gmail Settings:
Localhost
Login
SSL
smtp.gmail.com
Port: 465
user / pass
Reply-to: No
Return-path: No

Godaddy Settings:
Localhost
Login
SSL
smtpout.secureserver.net
Port: 465
user / pass
Reply-to: No
Return-path: No

@srenon
Copy link
Contributor

srenon commented Jan 11, 2017

@pmagony ... connection time out normally mean something is blocking the connect to gmail server. ( i have not use godaddy servers in years and back then you had to do "something special to send email") eg https://www.godaddy.com/help/specifying-an-email-address-for-the-php-form-mailer-508

Was Magento sending emails before installing this extension?

What is the output of the following command

php -r "mail('s@gmail.com', 'My Subject', 'test');"

telnet smtp.gmail.com 465

@bfsmith07
Copy link
Author

Did anyone ever find a working solution? I tried the fix from @coresh and it worked fine at first. Now i'm getting a new error: Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in vendor/magento/zendframework1/library/Zend/Mail/Protocol/Abstract.php on line 268.

@kodeakpaul
Copy link

@coresh I'm using PHP Version 5.6.30, ill trying switching PHP version and let you know.

@kodeakpaul
Copy link

@coresh I installed PHP Version 7.0.15, I'm having the same issues, I have even uninstalled the manual install and did a clean install through composer, still no go. Incorrect authentication data

@kodeakpaul
Copy link

@coresh I ended up doing this: http://magento.stackexchange.com/questions/92860/magento-2-smtp-settings and now it works.

@coresh
Copy link

coresh commented Jan 29, 2017

@Truxxx Great!

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

6 participants