<blockquote>
WordPress在万网空间无法发送邮件的解决办法
WordPress默认使用的是stream_socket_client函数发送邮件,而万网空间却支持的是fsockopen函数,所以在万网虚拟主机上,安装wordpress 默认安装smtp插件,是无法发送邮件。
解决办法:
找到wp-includes文件夹里面的class-smtp.php文件, 搜索stream_socket_client字段(大约202行)。找到如下代码
[cce_php] $this->smtp_conn = @stream_socket_client( $host . “:” . $port, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $socket_context ); [/cce_php]
注释掉这段话。如下所示:
[cce_php] /* $this->smtp_conn = @stream_socket_client( $host . “:” . $port, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $socket_context ); */ [/cce_php]
接着在这段代码的上一行添加如下代码
[cce]$this->smtp_conn = fsockopen($host, $port, $errno, $errstr);[/cce]
修改好的代码如下所示:
// Connect to the SMTP server
$errno = 0;
$errstr = ”;
$socket_context = stream_context_create($options);
//Suppress errors; connection failures are handled at a higher level
$this->smtp_conn = fsockopen($host, $port, $errno, $errstr);
/*
$this->smtp_conn = @stream_socket_client(
$host . “:” . $port,
$errno,
$errstr,
$timeout,
STREAM_CLIENT_CONNECT,
$socket_context
);
*/
</blockquote>
文章评论