The small editor first encountered a solution to sending an email with the prompt "cocould not connect to SMTP host". After the solution, it was found that wordpress is now in version 4.0, and the above method is not enough, certainly cannot solve the problem. Now, let's look at it again.
Fsockopen () is disabled because "cannot connect to SMTP server." (Error: cocould not connect to SMTP host) occurs when an email is sent.
If the fsockopen () function is disabled on the server, the above error occurs when PHPmailer connects to the remote SMTP server.
Mingkai uses the Configure SMTP plug-in for testing. The results are as follows.
The solution is as follows:
For your own server, directly edit php. ini and find fsockopen in disable_function and delete it. Restart php and try again.
If you cannot change php. ini, use
Pfsockopen ()Replace functions directly
Fsockopen ()
If the pfsockopen function is disabled, you can use the Socket function instead of other functions, as shown in figure
Stream_socket_client ()
For example, wordpress sends an email:
Find the wp-nodes des/class. smtp. php file.
Set
Change @ fsockopen to @ pfsockopen.
The code is as follows: |
Copy code |
$ This-& gt; smtp_conn = @ fsockopen ( $ Host, // the host of the server $ Port, // the port to use $ Errno, // error number if any $ Errstr, // error message if any $ Tval); // give up after? Secs // Verify we connected properly Change $ This-& gt; smtp_conn = @ pfsockopen ( $ Host, // the host of the server $ Port, // the port to use $ Errno, // error number if any $ Errstr, // error message if any $ Tval); // give up after? Secs // Verify we connected properly |
The above method is only applicable to versions earlier than 3.8 and is also an all-online solution. If the version is later than 3.9, no result will be returned.
For versions later than 3.8, remove the @ pfsockopen function due to security issues.
However, all the methods on the Internet are copied, which has no effect.
After studying this, Mingkai found the following problems and solutions.
Version 3.8 uses fsockopen to send a socket. Which of the following versions will be used later?
Stream_socket_clientSend socket.
Php. ini is disabled by default.
Stream_socket_clientThis function.
Versions earlier than 3.8:
Versions earlier than 3.8:
Let's take a look at the phpinfo information:
This function is disabled.
You can modify php. ini:
Delete
Stream_socket_clientYou can.
Let's take a look. View the effect