Phpmailer using smtp with Gmail not working - connection timing out

前端 未结 8 1988
天命终不由人
天命终不由人 2020-12-11 07:52

I\'ve looked into the following links:

phpmailer send gmail smtp timeout

send email using Gmail SMTP server through PHP Mailer

http://uly.me/phpmaile

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 08:10

    I dug into it. Use fsocketopen, which is native to php, to test the connection and eliminate most of the potential problems. Write a simple php page with this:

        $host = "smtp.gmail.com";
        $port = "587";
        $checkconn = fsockopen($host, $port, $errno, $errstr, 5);
        if(!$checkconn){
            echo "($errno) $errstr";
        } else {
            echo 'ok';
        }
    

    You should get back "ok". If not you know you have a connection problem that has nothing to do with Phpmailer. If that's the case it's probably the hosting company. If not then it's probably something simple about the difference between your local host and the hosting company like different versions of php.

    I suspect though that this script won't make the connection

提交回复
热议问题