WordPress3.8 failure to use smtp to send mail problem solving tutorial

Source: Internet
Author: User
Tags ini php file php and

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.