【问题标题】:PHP mailer errorPHP 邮件程序错误
【发布时间】:2011-01-14 17:21:28
【问题描述】:

我尝试使用php mailer但错误如下。

SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. Message could not be sent.

Mailer Error: SMTP Error: Could not authenticate. 

还有我的代码

 <?php
        require("class.phpmailer.php")
        $mail = new PHPMailer();        
        $mail->IsSMTP();                                    
        $mail->Host = "smtp.gmail.com";  
        $mail->Port = 465;        
        $mail->SMTPAuth = true;     

        $mail->SMTPDebug = 2;  
        $mail->Username = "admin@xxxxxxxxxxxx.in";  
        $mail->Password = "xxxxxxxx";   
        $mail->From = "admin@xxxxxxxxxxxx.in";
        $mail->FromName = "Mailer";
        $mail->AddAddress("xxxx@yahoo.co.in", "mine");               
        $mail->WordWrap = 50;                                 
        $mail->IsHTML(true);                                  

        $mail->Subject = "Here is the subject"  
        $mail->Body    = "This is the HTML message body <b>in bold!</b>";
        $mail->AltBody = "This is the body in plain text for non-HTML mail clients";


        if(!$mail->Send())  {
           echo "Message could not be sent. <p>";
           echo "Mailer Error: " . $mail->ErrorInfo;
           exit;
        }
        echo "Message has been sent";

        ?>

【问题讨论】:

  • 您需要安全连接,不是吗?

标签: php phpmailer


【解决方案1】:

不确定,但请尝试$mail-&gt;Host = "smtp.gmail.com" =&gt;$mail-&gt;Host = "smtp.google.com"

【讨论】:

    【解决方案2】:

    可能是因为防火墙?

    如果您无法登录 Google Talk, 或者您收到一个错误 说,无法验证 服务器,检查你是否有个人 安装了防火墙软件,或者如果 您的计算机位于代理服务器后面 这需要用户名和密码。

    http://www.google.com/support/talk/bin/answer.py?hl=en&answer=30998

    【讨论】:

    • 谈话不是邮件,不是吗?
    【解决方案3】:

    某些服务器(尤其是共享主机)会阻止您将 SSL 与 SMTP 一起使用,我曾经遇到过同样的问题。

    如果可以,请更改主机,尝试使用默认的 PHP mail() 函数或通过另一个不需要 SSL 的邮件服务器发送,例如端口 25 而不是 465。

    AuthSMTP 之类的东西是您最好的备用邮件服务器选择。

    【讨论】:

    • 我尝试使用 PHp 邮件功能,但邮件也没有被发送。
    【解决方案4】:

    由于 SSL 端口错误,我得到了这个。

    SSL = 465 TLS = 587

    见: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

    【讨论】:

    • 这个答案......这是经过多次故障排除后终于为我工作的答案。谢谢先生。
    【解决方案5】:

    如果您在本地工作,只需转到 PHP 扩展 并启用或检查 php_openssl 它将能够访问 SSL 端口。

    【讨论】:

      【解决方案6】:

      我有同样的问题,似乎我们有 设置 SMPTSecure 值。 首先,我将端口从 465 更改为 587 并添加:
      $mail->SMTPSecure = "tls"; 它奏效了:)

      【讨论】:

        【解决方案7】:

        我对多个客户端使用相同的脚本,并且仅在部署到 Amazon EC2 云提供商(例如 Openshift)时遇到此问题。

        这些是 phpmailer 中经过试验和测试的设置: $mail->SMTPSecure = "tls"; // 设置服务端的前缀 $mail->Host = "smtp.gmail.com"; // 将 GMAIL 设置为 SMTP 服务器 $邮件->端口= 587;

        “但是”Google 将这些服务作为一种“反垃圾邮件”/政治策略来阻止,这让我感到震惊,因为它在本地和大多数托管服务提供商上都有效,当他们不接受时,你无能为力来自您的主机 DNS / IP 的出站消息。接受它并继续寻找另一个 smtp 服务器来路由消息。

        【讨论】:

          【解决方案8】:

          试试这个代码

          require 'PHPMailerAutoload.php';
          
              //Create a new PHPMailer instance
              $mail = new PHPMailer();
              //Tell PHPMailer to use SMTP
              $mail->IsSMTP(); 
              //Enable SMTP debugging
              // 0 = off (for production use)
              // 1 = client messages
              // 2 = client and server messages
              //$mail->SMTPDebug = 2;
          
              //Ask for HTML-friendly debug output
              //$mail->Debugoutput = 'html';
          
              //Set the hostname of the mail server
              $mail->Host = 'smtp.gmail.com';
          
              //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
              $mail->Port = 465;
          
              //Set the encryption system to use - ssl (deprecated) or tls
              $mail->SMTPSecure = 'ssl';
          
              //Whether to use SMTP authentication
              $mail->SMTPAuth = true;
          
              //Username to use for SMTP authentication - use full email address for gmail
              $mail->Username = "admin@gmail.com";
          
              //Password to use for SMTP authentication
              $mail->Password = "admin123";
          
              $mail->setFrom('admin3@gmail.com', 'development');  //add sender email address.
          
              $mail->addAddress('admins@gmail.com', "development");  //Set who the message is to be sent to.
              //Set the subject line
              $mail->Subject = $response->subject;
          
              //Read an HTML message body from an external file, convert referenced images to embedded,
              //convert HTML into a basic plain-text alternative body
              $mail->Body     = 'Name: '.$data['name'].'<br />Location: '.$data['location'].'<br />Email: '.$data['email'].'<br />Phone:'.$data['phone'].'<br />ailment: '.$data['ailment'].'<br />symptoms: '.$data['symptoms'];
          
              //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.gif');
              //$mail->SMTPAuth = true;
              //send the message, check for errors
              if (!$mail->send()) {
                  echo "Mailer Error: " . $mail->ErrorInfo;
              } else {
                  echo "Message sent!";
              }
          

          【讨论】:

          • $mail->SMTPSecure = 'ssl';为我带来了改变,谢谢!
          • @Cyrille Armanger 如果可行,请接受答案:) 提前谢谢
          • 我不是原创者,它只是帮助了我。
          【解决方案9】:

          遇到同样的问题,将 opencart 邮件设置中的端口号更改为 587 即可正常工作

          【讨论】:

            猜你喜欢
            • 2015-08-10
            • 1970-01-01
            • 1970-01-01
            • 2017-06-24
            • 1970-01-01
            • 1970-01-01
            • 2011-02-05
            • 2014-08-28
            • 1970-01-01
            相关资源
            最近更新 更多