HiChina hosts all seem to need to send emails through SMTP, and enable fsockopen. However, the SMTP sending method of WordPress is steam_connect_client instead of fsockopen.
HiChina hosts all seem to need to send emails through SMTP, and to enable fsockopen (this can be enabled in HiChina background. if not, please contact HiChina customer service ). But the SMTP sending method of WordPress is steam_connect_client rather than fsockopen, so open/wp-include/class-smtp.php is about 274-282 line location, 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
);
Modify it to the following code:
$ This-> smtp_conn = @ fsockopen ($ host, $ port, $ errno, $ errstr, $ timeout );
Then use the SMTP plug-in such as wp smtp or wp mail smtp to send emails. you can configure it.
Note: This method directly modifies the core code of WordPress. once you upgrade the WordPress version, you need to modify it again. please REMEMBER !!!
The above is the details about how to solve the problem that wordpress cannot send emails to SMTP on the HiChina host. For more information, see other related articles in the first PHP community!