Solution to the problem that Wanwang host WordPress cannot send SMTP emails

PHPz
Release: 2023-03-07 09:02:01
Original
2635 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template