The SMTP sending method of wordpress uses steam_connect_client, while the HiChina host provides fsockopen, so to send the mail smoothly, you also need to modify the source file class-smtp.php of the wordpress program, change the SMTP sending method of wordpres to fsockopen to cater to HiChina hosts.
1. The fsockopen function of the HiChina host is disabled by default. Enable the fsockopen function on the HiChina host management panel:
Fsockopen function description
Fsockopen-open a network connection or a Unix socket connection
Description
Resource fsockopen (string $ hostname [, int $ port =-1 [, int & $ errno [, string & $ errstr [, float $ timeout = ini_get ("default_socket_timeout")])
Initialize a socket to connect to the specified host (hostname ).
Parameters
Hostname
If OpenSSL is installed, you may need to add the access protocol ssl: // or tls: // before your host name address ://, therefore, you can use an SSL or TLS client based on the TCP/IP protocol to connect to a remote host.
Port
The port number. If you pass a-1 parameter, the port is not used, for example, unix ://.
Errno
If this parameter is passed in, holds the system level error number that occurred in the system-level connect () call.
If the returned value of errno is 0 and the returned value of this function is FALSE, this indicates that the error occurred before the socket connection (connect () call, the biggest cause of connection failure is that an error occurs during socket initialization.
Errstr
The error message is returned as a string.
Timeout
Sets the connection time limit, in seconds.
2. Edit the class-smtp.php file under the wp-include/directory and find the following code:
$ Socket_context = stream_context_create ($ options );
$ This-> smtp_conn = @ stream_socket_client (
$ Host. ":". $ port,
$ Errno,
$ Errstr,
$ Timeout,
STREAM_CLIENT_CONNECT,
$ Socket_context
);
Replace with the following code:
$ This-> smtp_conn = @ fsockopen ($ host, $ port, $ errno, $ errstr, $ timeout );
Tip: The QQ mailbox still cannot send emails occasionally. There is no problem in the 163 mailbox test.