It seems that Wanwang's hosts need to send emails through SMTP, and fsockopen must be turned on (it can be turned on in Wanwang's background. If not, please contact Wanwang customer service). However, the SMTP sending method of WordPress is steam_connect_client instead of fsockopen. Therefore, open /wp-include/class-smtp.php at about line 274-282 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
);
Change to the following code:
$this->smtp_conn = @fsockopen($host,$ port,$errno,$errstr,$timeout);
Then use WP SMTP or WP MAIL SMTP, a plug-in for SMTP to send emails. Once configured, it will be fine.
Special note: Since this method directly modifies the core code of WordPress, once the WordPress version is upgraded, it needs to be modified again, so please remember! ! !
The above is the detailed content of Solution to the problem that Wanwang host WordPress cannot send SMTP emails. For more information, please follow other related articles on the PHP Chinese website!