2013-01-12 3 views
20

localhost上で実行されているのと同じPHPスクリプトを使用しています。私のPCからは動作しますが、ホストされたサーバからは動作しません。GMailとphpMailerで送信するときに、「サーバーから受け入れられないパスワード:535不正確な認証データ」

私がホストされたサーバーからそれを送信すると、私は次のような出力が得られます。

SMTP -> ERROR: Password not accepted from server: 535 Incorrect authentication data 
SMTP -> ERROR: RCPT not accepted from server: 550-Please turn on SMTP Authentication in your mail client, or login to the 550-IMAP/POP3 server before sending your message. dev.camppage.com 550-(patchvalues.com) [205.234.141.238]:50958 is not permitted to relay through 550 this server without authentication. 
SMTP Error: The following recipients failed: [email protected] FAILED 

私は、サーバー上で変更する必要がある構成設定がある疑いがあるが、私はどちらかわかりません。どんなアドバイスも大歓迎です!ここ

コードされる:

function send_gmail ($recipients, $subject, $message, $attachment_filenames = array()) 
{ 
    global $email_address, $email_password, $email_name; 
    require_once ($_SERVER['DOCUMENT_ROOT']. '/php/PHPMailer/class.phpmailer.php'); 

    $body = $message; 
    $body = str_replace("\\", '', $body); 
    $mail = new PHPMailer(); 
    $mail->CharSet = "UTF-8"; 
    $mail->IsSMTP(); 
    $mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
    $mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 0 - none; 1 - errors & messages; 2 - messages only 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->SMTPSecure = "ssl";     // sets the prefix to the servier 
    $mail->Port  = 465;     // set the SMTP port 
    $mail->Username = $email_address; // GMAIL username 
    $mail->Password = $email_password; // GMAIL password 
    $mail->SetFrom($email_address); 
    $mail->FromName = $email_name; 
    $mail->AddReplyTo($email_address,$email_name); 
    $mail->Subject = $subject; 
    $mail->MsgHTML($body); 
    $mail->IsHTML(true); // send as HTML 

    if (isset ($recipients[0])) 
    { 
    foreach ($recipients AS $to) 
    { 
     $to_pieces = explode (",", $to, 2); 
     $to_email = trim ($to_pieces[0]); 
     if (isset ($to_pieces[1])) 
      $to_name = trim ($to_pieces[1]); 
     else 
      $to_name = " "; 
     $mail->AddAddress($to_email, $to_name); 
    } 
    $mail->IsHTML(true); // send as HTML 

    if ($mail->Send()){ 
     return TRUE; 
    } else { 
     return FALSE; 
    } 
} 
else 
{ 
    return FALSE; 
} 
} 

TIA

答えて

43

溶液は、サーバ設定から送信SMTPを有効にすることでした。

cPanelのWHMを実行しているサーバーでは、これはWHMの「微調整設定」セクションにあります。

オプションは、有効/無効 - 無効を選択します。

警告:この変更を行うと、送信SMTP接続がリダイレクトされ、アカウントが直接接続できるようになり、サーバーがブラックリストに登録される可能性が高くなります。

+8

あなたは命の恩人です。私はCentOS 6を使用しています。 'ログインにCPanel>調整設定>すべて> "送信SMTPをroot、exim、mailman(FKA SMTP Tweak)に制限する "" <==無効にします。私は同じ問題がある人のためにもっと詳しく説明します –

+1

あなたは人生の節約者です。私を救うためにあなたのヒーロースーツをどこにも出てこなかったとき、私は欲求不満の射撃部隊の前にいました。ありがとう – Temitayo

+0

はい。私の肌も救った。ありがとう! –

2

これはWHM/cPanelのに関連して、あなたが

"SMTP Mail protection has been disabled. All users may make outbound smtp connections." 

より多くの読書を取得する必要があります。この

/scripts/smtpmailgidonly off 

を入力して、前の回答で、またはシェルから同じことを行うことができますここをクリックhttps://forums.cpanel.net/threads/cant-enable-smtp-restrictions.360971/

関連する問題