万网免费主机smtp邮件回复失效的解决办法

  • 14
  • 9,016 views
  • A+
所属分类:wordpress

网站搬家到万网也遇到了一些小问题,搬家的过程还算顺利,但是也遇到了一点小问题,邮件回复功能又失效了。上网查询了一下,需要使用fsockopen函数。但是WordPress的SMTP默认发送方式为steam_connect_client而非fsockopen,所以需要打开/wp-include/class-smtpp.php 200-209行左右,将

$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);

就行了,当然前提是万网虚拟主机PHP.ini设置那里要保证fsockopen函数是打开的。
万网免费主机smtp邮件回复失效的解决办法

 

wordpress4.3已变成273-297行

if ($streamok) {
$socket_context = stream_context_create($options);
//Suppress errors; connection failures are handled at a higher level
$this->smtp_conn = @stream_socket_client(
$host . ":" . $port,
$errno,
$errstr,
$timeout,
STREAM_CLIENT_CONNECT,
$socket_context
);
} else {
//Fall back to fsockopen which should work in more places, but is missing some features
$this->edebug(
"Connection: stream_socket_client not available, falling back to fsockopen",
self::DEBUG_CONNECTION
);
$this->smtp_conn = fsockopen(
$host,
$port,
$errno,
$errstr,
$timeout
);
}

weinxin
我的微信公众号
我的微信公众号扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:14   其中:访客  0   博主  0

    • 麦新杰 麦新杰 3

      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

      我也是用的这个方法,但是有个问题,垃圾评论正常是不会发邮件提醒的,但是这样修改之后,垃圾评论会发送邮件提醒(这些评论还是进垃圾箱)。有无办法?

        • 厘米 厘米 9

          Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

          @麦新杰 拉到评论黑名单,然后有评论等待审核时那里不要发送电子邮件。再不行就用Akismet等插件!

            • 麦新杰 麦新杰 3

              Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

              @厘米 就是使用的Akismet插件,评论都是进垃圾箱的,唯一的问题就是多了一个发送邮件。

                • 厘米 厘米 9

                  Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                  @麦新杰 后台设置何时发送电子邮件那里-有评论等待审核时你是不是勾选了?

                    • 麦新杰 麦新杰 3

                      Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                      @厘米 这个是需要勾选的,正常情况,系统只有非垃圾评论才会发邮件。

              • 同盟源 同盟源 7

                Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                我的映像中万网的主机是支持mail函数的

                  • 厘米 厘米 9

                    Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                    @同盟源 可能付费主机支持,免费主机限制的还是比较多的!

                  • 控海无边 控海无边 5

                    Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                    你的网站终于好啦,备案搬家做好啦,恭喜 :razz:

                      • 厘米 厘米 9

                        Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                        @控海无边 嗯嗯,恢复更新~ :smile:

                      • 小子 小子 4

                        Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                        你的方法成功啦 找了好几个都是不行了 终于好了 哈哈

                          • 厘米 厘米 9

                            Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                            @小子 好了就好啊!

                              • 小子 小子 4

                                Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                                @厘米 恩呢 你用的什么插件?

                                  • 厘米 厘米 9

                                    Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                                    @小子 我是主题自带的smtp功能~

                                      • 小子 小子 4

                                        Warning: Use of undefined constant auto - assumed 'auto' (this will throw an Error in a future version of PHP) in /www/wwwroot/past.cmsky.org/wp-content/themes/begin5.2/inc/inc.php on line 911

                                        @厘米 哦哦 那就算了 嘿嘿