我试图使用PHP邮件收发器,但误差如下:

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";

        ?>
有帮助吗?

解决方案

某些服务器(特别是共享托管)将阻止从使用SSL与SMTP,我有同样的问题一次。

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

AuthSMTP 的东西将是一个备用邮件服务器你最好的选择。

其他提示

我正在此由于错误的端口,用于SSL

SSL = 465 TLS = 587

请参阅: http://mail.google.com/support/bin/answer.py?hl=烯&回答= 13287

我有同样的问题,我们似乎有 设置SMPTSecure值。 首先,我改变了口,从465到587,并补充道:点击 $ MAIL-> SMTPSecure = “TLS”; 和它的工作:)

如果你在你的本地主机的工作只是去到 PHP扩展并启用或检查 php_openssl 它将能够访问SSL端口。

尝试此代码

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!";
    }

可能是因为火壁的?

  

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

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

我使用相同的脚本为多个客户端和仅部署到亚马逊EC2云供应商时(如Openshift)遇到这个问题。

这些尝试和在PHPMailer的测试设置:     $ MAIL-> SMTPSecure = “TLS”; //将前缀施维雅     $ MAIL->主机= “smtp.gmail.com”; //将Gmail作为SMTP服务器     $ MAIL->端口= 587;

“而是”谷歌阻止这些服务作为“反垃圾邮件” /政治伎俩,而这也抓住了我,因为它工作在本地和大多数托管服务提供商,并没有什么太多的时候,他们不接受,你可以做从您的主机的DNS / IP出站邮件。接受它,并通过寻找通过另一个SMTP服务器路由消息前进。

有同样的问题,更改端口号在Opencart的邮件设置为587和正常工作

不知道,但尝试$mail->Host = "smtp.gmail.com" =>$mail->Host = "smtp.google.com"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top