第一步、在万网的免费虚拟主机后台启用fsockopen函数(PHP.in设置 → PHP函数设置)。如下图所示:
第二步、修正WordPress程序中wp-includes/class-smtp.php文件,找到以下内容部分(202行旁边):
$this->smtp_conn = @stream_socket_client( $host . ":" . $port, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $socket_context );
修正为:

$this->smtp_conn = fsockopen($host, $port, $errno, $errstr);
第三步、安装WP SMTP插件(国人开拓的一款插件)https://wordpress.org/plugins/wp-smtp/ ,供应一个免插件实现SMTP邮件做事的方法,将以下代码添加到主题functions.php文件中:
//利用smtp发送邮件,以163邮箱为例add_action('phpmailer_init', 'mail_smtp');function mail_smtp( $phpmailer ) {$phpmailer->FromName = '氪星人'; //发件人的名称$phpmailer->Host = 'smtp.163.com'; //修正为你利用的SMTP做事器$phpmailer->Port = 25; //SMTP端口$phpmailer->Username = 'lyc@163.com'; //你的邮箱账号$phpmailer->Password = ''; //邮箱密码$phpmailer->From = 'admin@163.com'; //你的邮箱账号$phpmailer->SMTPAuth = true;$phpmailer->SMTPSecure = ''; //ssl对应的端口465$phpmailer->IsSMTP();}