10

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

        ?>
4

9 に答える 9

21

SSLのポートが間違っているためにこれを取得していました。

SSL = 465 TLS = 587

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

于 2011-09-18T22:03:55.623 に答える
14

一部のサーバー(特に共有ホスティング)では、SMTPでSSLを使用できなくなります。同じ問題が発生したことがあります。

可能であればホストを変更するか、デフォルトのPHP mail()関数を使用するか、SSLを必要としない別のメールサーバー(たとえば、465ではなくポート25)を介して送信してください。

AuthSMTPのようなものは、代替メールサーバーの最善の策です。

于 2010-02-09T09:42:29.177 に答える
9

同じ問題が発生しました。SMPTSecure値を設定する必要があるようです。まず、ポートを465から587に変更し、次を追加しました。
$ mail-> SMTPSecure = "tls"; そしてそれはうまくいきました:)

于 2013-03-20T12:55:46.253 に答える
5

ローカルホストで作業している場合は、PHP拡張機能に移動し、 php_opensslを有効または確認するだけ で、SSLポートにアクセスできるようになります。

于 2012-08-30T05:58:54.613 に答える
3

このコードを試してください

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!";
    }
于 2014-09-08T12:31:12.680 に答える
3

同じ問題がありました。opencartメール設定のポート番号を587に変更すると、正常に機能します。

于 2015-11-06T06:36:36.133 に答える
2

防火壁のせいかもしれませんか?

Googleトークにサインインできない場合、または「サーバーへの認証ができませんでした」というエラーが表示された場合は、パーソナルファイアウォールソフトウェアがインストールされているかどうか、またはコンピュータがユーザー名とユーザー名を必要とするプロキシサーバーの背後にあるかどうかを確認してください。パスワード。

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

于 2010-02-09T08:41:27.253 に答える
2

複数のクライアントに同じスクリプトを使用していますが、Amazon EC2クラウドプロバイダー(Openshiftなど)にデプロイする場合にのみこの問題が発生します。

これらは、phpmailerで試行およびテストされた設定です。$ mail-> SMTPSecure = "tls"; //プレフィックスをservierに設定します$mail->Host = "smtp.gmail.com"; //GMAILをSMTPサーバーとして設定します$mail->Port = 587;

「しかし」Googleはこれらのサービスを「スパム対策」/政治的策略としてブロックしています。これはローカルおよびほとんどのホスティングプロバイダーで機能するため、私を捕らえました。ホストのDNS/IP。それを受け入れて、メッセージをルーティングする別のSMTPサーバーを探して先に進みます。

于 2014-04-09T06:39:02.703 に答える
1

わからないが試してみてください$mail->Host = "smtp.gmail.com" =>$mail->Host = "smtp.google.com"

于 2010-02-09T08:36:40.090 に答える