<bdo id='KYR5L'></bdo><ul id='KYR5L'></ul>

    <i id='KYR5L'><tr id='KYR5L'><dt id='KYR5L'><q id='KYR5L'><span id='KYR5L'><b id='KYR5L'><form id='KYR5L'><ins id='KYR5L'></ins><ul id='KYR5L'></ul><sub id='KYR5L'></sub></form><legend id='KYR5L'></legend><bdo id='KYR5L'><pre id='KYR5L'><center id='KYR5L'></center></pre></bdo></b><th id='KYR5L'></th></span></q></dt></tr></i><div id='KYR5L'><tfoot id='KYR5L'></tfoot><dl id='KYR5L'><fieldset id='KYR5L'></fieldset></dl></div>
    1. <small id='KYR5L'></small><noframes id='KYR5L'>

    2. <legend id='KYR5L'><style id='KYR5L'><dir id='KYR5L'><q id='KYR5L'></q></dir></style></legend>
    3. <tfoot id='KYR5L'></tfoot>

        PHPMailer,SMTP 连接()失败错误与 Gmail

        PHPMailer, SMTP connect() failed error with Gmail(PHPMailer,SMTP 连接()失败错误与 Gmail)
        • <bdo id='d8bRW'></bdo><ul id='d8bRW'></ul>

              1. <legend id='d8bRW'><style id='d8bRW'><dir id='d8bRW'><q id='d8bRW'></q></dir></style></legend>

                <i id='d8bRW'><tr id='d8bRW'><dt id='d8bRW'><q id='d8bRW'><span id='d8bRW'><b id='d8bRW'><form id='d8bRW'><ins id='d8bRW'></ins><ul id='d8bRW'></ul><sub id='d8bRW'></sub></form><legend id='d8bRW'></legend><bdo id='d8bRW'><pre id='d8bRW'><center id='d8bRW'></center></pre></bdo></b><th id='d8bRW'></th></span></q></dt></tr></i><div id='d8bRW'><tfoot id='d8bRW'></tfoot><dl id='d8bRW'><fieldset id='d8bRW'></fieldset></dl></div>
              2. <small id='d8bRW'></small><noframes id='d8bRW'>

                • <tfoot id='d8bRW'></tfoot>

                    <tbody id='d8bRW'></tbody>
                  本文介绍了PHPMailer,SMTP 连接()失败错误与 Gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试制作联系表格,并且正在使用 PHPMailer.我在 localhost 上用 xampp 试过了,效果很好.但是当我上传到我的主机时,我收到错误 SMTP connect() failed.

                  I’m trying to make a contact form and I’m using PHPMailer. I tried that on localhost with xampp and it works perfect. But when i upload to my host i get the error SMTP connect() failed.

                  这是我的代码:

                  $m = new PHPMailer;
                  
                  $m->isSMTP();
                  $m->SMTPAuth = true;
                  
                  $m->Host = "smtp.gmail.com";
                  $m->Username = "mymail@gmail.com";
                  $m->Password = "mypass";
                  $m->SMTPSecure = "ssl";
                  $m->Port = "465";
                  
                  $m->isHTML();
                  
                  $m->Subject = "Hello world";
                  $m->Body = "Some content";
                  
                  $m->FromName = "Contact";
                  
                  $m->addAddress('mymail@gmail.com', 'Test');
                  

                  我尝试将端口更改为 587,将 SMTPsecure 更改为 tls(以及所有组合).但不起作用.有什么建议可以解决这个问题?

                  I've tried to change the port to 587 and the SMTPsecure to tls (and all the combinations). But doesn’t work. Any advice to solve this?

                  谢谢

                  推荐答案

                  您可能需要指定发送消息的地址,如下所示:

                  You may need to specify the address from which the message is going to be sent, like this:

                  $mail->From = 'user@domain.com';
                  

                  我也会给 isHTML 一个参数,无论是真还是假:

                  I would also give isHTML a parameter, either true or false:

                  $m->isHTML(true);
                  

                  另一种选择是尝试同时删除端口规范.您可能会发现其他几个有用的参数.下面的例子是我测试过的代码,看看你能不能适应你的使用:

                  Another option is trying to drop the port specification all together. There are several other parameters that you may find useful. The following example is code I've tested, see if you can adapt it for your uses:

                  $mail = new PHPMailer;
                  $mail->isSMTP();/*Set mailer to use SMTP*/
                  $mail->Host = 'mail.domain.com';/*Specify main and backup SMTP servers*/
                  $mail->Port = 587;
                  $mail->SMTPAuth = true;/*Enable SMTP authentication*/
                  $mail->Username = $username;/*SMTP username*/
                  $mail->Password = $password;/*SMTP password*/
                  /*$mail->SMTPSecure = 'tls';*//*Enable encryption, 'ssl' also accepted*/
                  $mail->From = 'user@domain.com';
                  $mail->FromName = $name;
                  $mail->addAddress($to, 'Recipients Name');/*Add a recipient*/
                  $mail->addReplyTo($email, $name);
                  /*$mail->addCC('cc@example.com');*/
                  /*$mail->addBCC('bcc@example.com');*/
                  $mail->WordWrap = 70;/*DEFAULT = Set word wrap to 50 characters*/
                  $mail->addAttachment('../tmp/' . $varfile, $varfile);/*Add attachments*/
                  /*$mail->addAttachment('/tmp/image.jpg', 'new.jpg');*/
                  /*$mail->addAttachment('/tmp/image.jpg', 'new.jpg');*/
                  $mail->isHTML(false);/*Set email format to HTML (default = true)*/
                  $mail->Subject = $subject;
                  $mail->Body    = $message;
                  $mail->AltBody = $message;
                  if(!$mail->send()) {
                      echo 'Message could not be sent.';
                      echo 'Mailer Error: ' . $mail->ErrorInfo;
                  } else {
                      header("Location: ../docs/confirmSubmit.html");
                  }
                  

                  希望这会有所帮助!

                  这篇关于PHPMailer,SMTP 连接()失败错误与 Gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                  Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)
                    <tbody id='bAV26'></tbody>
                  <tfoot id='bAV26'></tfoot>
                  <legend id='bAV26'><style id='bAV26'><dir id='bAV26'><q id='bAV26'></q></dir></style></legend>

                    <small id='bAV26'></small><noframes id='bAV26'>

                      • <bdo id='bAV26'></bdo><ul id='bAV26'></ul>

                          <i id='bAV26'><tr id='bAV26'><dt id='bAV26'><q id='bAV26'><span id='bAV26'><b id='bAV26'><form id='bAV26'><ins id='bAV26'></ins><ul id='bAV26'></ul><sub id='bAV26'></sub></form><legend id='bAV26'></legend><bdo id='bAV26'><pre id='bAV26'><center id='bAV26'></center></pre></bdo></b><th id='bAV26'></th></span></q></dt></tr></i><div id='bAV26'><tfoot id='bAV26'></tfoot><dl id='bAV26'><fieldset id='bAV26'></fieldset></dl></div>