WordPress增加了fsockopen功能

将博客从景安的免费主机搬到阿里云的免费主机上,之前在上面搭建过,发现是不能自动发信,要更改文件才可以,可以看《万网的免费虚拟主机用着没那么方便》。

博客使用的是smtp插件,在后台我测试了下发信功能,邮箱竟然收到邮件了。开始以为文件我之前修改过,所以到WordPress 4.3.1版本的源文件里查看了下,看到了fsockopen

       // Connect to the SMTP server

        $this->edebug(

            "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true),

            self::DEBUG_CONNECTION

        );

        $errno = 0;

        $errstr = '';

        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

            );

        }

又找了之前版本的wordpress,里面的内容是

        // 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 = @stream_socket_client(

            $host . ":" . $port,

            $errno,

            $errstr,

            $timeout,

            STREAM_CLIENT_CONNECT,

            $socket_context

        );

这样可以看出,这个版本目前是先选择stream_socket_client函数,如果这个函数不能使用,则使用fsockopen函数。


已发布

分类

作者:

标签

评论

《“WordPress增加了fsockopen功能”》 有 1 条评论

  1. 好文章 的头像

    过来看看、支持一下

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注