解决万网主机下 WordPress 无法发送邮件的问题

不少朋友一直都在问万网主机下 WordPress 无法发送邮件,其实在WordPress大学的问答中心, Jerry8yuan 给出了解决方案,下面简单整理一下,方便后面的朋友。

万网的主机貌似都需要通过 SMTP 来发送邮件,而且要开启 fsockopen(在万网后台可以开启,不会的请联系万网客服) 。但是 WordPress 的 SMTP 发送方式为 steam_connect_client 而非fsockopen,所以,打开 /wp-include/class-smtp.php 大概是 274-282 行的位置,查找到下面的代码:

$socket_context = stream_context_create($options);
$this->smtp_conn = @stream_socket_client(
$host . ":" . $port,
$errno,
$errstr,
$timeout,
STREAM_CLIENT_CONNECT,
$socket_context
);

修改为如下代码:

$this->smtp_conn = @fsockopen($host,$port,$errno,$errstr,$timeout);

然后使用 WP SMTPWP MAIL SMTP 这类 SMTP 发送邮件的插件,配置好一般就可以了。

特别注意:由于这个方法是直接修改了 WordPress 的核心代码,一旦升级了 WordPress 版本,就需要重新进行修改,请务必记得!!!

来源:

https://www.wpdaxue.com/wanwang-host-send-email.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33677.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?