【问题标题】:PHPMailer error Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()PHPMailer 错误连接:打开到 ssl://smtp.gmail.com:465, timeout=300, options=array ()
【发布时间】:2017-01-26 20:29:30
【问题描述】:

您好,我正在尝试使用 PHPMailer,但它不工作给我错误

连接:打开到 ssl://smtp.gmail.com:465, timeout=300, options=array ()

这是我的代码

     require_once('mailFiles/PHPMailerAutoload.php');
echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."<br/>";
                $mail = new PHPMailer();
                $mail->isSMTP();
                $mail->SMTPDebug = 4;
                $mail->Debugoutput = 'html';
                $mail->SMTPAuth = true;
                $mail->SMTPSecure = 'ssl';
    //            $mail->SMTPSecure = 'tls';
                $mail->Host = 'smtp.gmail.com';
    //            $mail->Host = gethostbyname('smtp.gmail.com');
    //            $mail->Host = 'tls://smtp.gmail.com:587';
    //            $mail->Port = 587;
                $mail->Port = 465;
                $mail->Username = "xs4arabiabahrain@gmail.com";
                $mail->Password = "mailpass";
                $mail->setFrom('mail@gmail.com', 'Firstz Last');
                $mail->addAddress('myemail@gmail.com', 'MAAGE-EMAIL User');
                $mail->IsHTML(true);

                //Set the subject line
                $mail->Subject = 'PHPMailer GMail SMTP test';
                //Read an HTML message body from an external file, convert referenced images to embedded,
                //convert HTML into a basic plain-text alternative body
                $mail->msgHTML('Hi test 123');
                //Replace the plain text body with one created manually
                $mail->AltBody = 'This is a plain-text message body';
                //Attach an image file
                //$mail->addAttachment('images/phpmailer_mini.png');
                $result = $mail->send();
                if (!$result) {
                    echo ("Mailer Error: "); 
                    echo ($mail->ErrorInfo);
                } else {
                    echo ("Message sent!"); 
                }

累了tls还是不行。

【问题讨论】:

  • $mail->Host = 'tls://smtp.gmail.com:587';
  • 现在仍然无法工作,出现错误连接:打开 smtp.gmail.com:587,超时 = 300,选项 = 数组() SMTP 错误:无法连接到服务器:尝试访问访问权限禁止的套接字。 (10013)
  • 我建议您阅读the PHPMailer troubleshooting guide 并按照它所说的去做。听起来您对 PHP 安装也有限制。
  • 我正在关注这个链接,我也从这里获得了这段代码,但不能在我的本地主机中工作,因为我已经启用了 open_ssl 以及其他任何需要的东西..?

标签: php email ssl phpmailer


【解决方案1】:

问题出在我的防病毒软件上,我使用的是 McAfee,您需要更改其设置,请按照此link 更改这些设置。我希望它对其他人也有帮助。

【讨论】:

    猜你喜欢
    • 2016-11-07
    • 1970-01-01
    • 2020-12-31
    • 1970-01-01
    • 2020-11-03
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    相关资源
    最近更新 更多