2017-01-04 3 views
0

私は電子メールを送信するためにPHPMailerを使用しています。電子メールは適切になっていますが、PHPメーラーを使用して送信された電子メールを開くときはいつでも、警告メッセージが表示されます。PHPを使用して電子メールを開いた後に警告メッセージを表示

注:$ phpMailerTextからアンカータグを削除した場合、警告は表示されません。アンカータグを追加すると警告メッセージが表示されます。

enter image description here

require 'mail/PHPMailerAutoload.php'; 
    $to = $email; 
    //Create a new PHPMailer instance 
    $mail = new PHPMailer; 

    //Enable SMTP debugging 
    // 0 = off (for production use) 
    // 1 = client messages 
    // 2 = client and server messages 
    $mail->SMTPDebug = 0; 

    //Ask for HTML-friendly debug output 
    $mail->Debugoutput = 'html'; 

    // Headers 
$headers = "Content-Type: text/plain; charset=\"utf-8\"\n" 
       . "X-mailer: smtp.gmail.com" . "\r\n" // this will identify the real sender 
       . "Precedence: bulk" . "\r\n" // this will say it is bulk sender 
       . "List-Unsubscribe:[email protected]\r\n" // this will reveal the OPT-OUT address 
       . "Reply-To: $to\n" 
       . "To: $to\n" 
       . "From: $to\n"; 

    //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 = 587; 

    //Set the encryption system to use - ssl (deprecated) or tls 
    $mail->SMTPSecure = 'tls'; 

    //Whether to use SMTP authentication 
    $mail->SMTPAuth = true; 

    //Username to use for SMTP authentication - use full email address for gmail 
    $mail->Username = "[email protected]"; 

    //Password to use for SMTP authentication 
    $mail->Password = "****"; 

    //Set who the message is to be sent from 
    $mail->setFrom('[email protected]', 'code'); 

    //Set an alternative reply-to address 
    $mail->addReplyTo('[email protected]', 'code'); 

    //Set who the message is to be sent to 
    $mail->addAddress($to, 'Customer'); 

    //Set the subject line 
    $mail->Subject = 'code'; 

    $phpMailerText="<!DOCTYPE HTML><html> 
    <head> 
    <title>HTML email</title> 
    </head> 
    <body> 

    <a href='http://www.companyname.com/changepassword.php?user_id=" .$User_id1."'>Create your password here</a> 
    </body> 
    </html>"; 

    $mail->msgHTML($phpMailerText); 

    //Replace the plain text body with one created manually 
    $mail->AltBody = ' '; 

    //send the message, check for errors 
    if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; 
    } else { 
    } 
+0

電子メールを送信するために使用する電子メールクライアントまたはWebアプリケーションである可能性が高いコンポーネントは、どのコンポーネントから警告が得られるか分かりません。もしそうなら、スパムメールとして評価される可能性が最も高い。それがあなたが確認しなければならないものです。受信した電子メールのソースコードを開き、スパム検出エンジンによってヘッダーが注入されているかどうかを確認します。これらは通常、どんな詳細についてのヒントを与えて、正確に評価につながります。それはあなたのメッセージを修正する良い出発点です。多くの場合、コンテンツ自体だけでなく、メッセージが送信され、構造化される方法です。 – arkascha

+0

Mr.arkaschaに返信してくれてありがとう、私はこれで新しく、これについて何も考えていない。 –

+0

確かに、私はあなたにいくつかの出発点を与えたのです。 _really_電子メールを開くには通常、一部のWebフロントエンドだけでなく、_real_電子メールクライアントが必要です。優れた電子メールクライアントは、「メッセージソースの表示」などのオプションを提供します。それがあなたが望むものです。 – arkascha

答えて

0

次のコードを試してみて、他のステップを実行します。

  1. は、リバースDNSレコードに
  2. SPFレコードの設定
$to = $email; 
//Create a new PHPMailer instance 
$mail = new PHPMailer; 

//Enable SMTP debugging 
// 0 = off (for production use) 
// 1 = client messages 
// 2 = client and server messages 
$mail->SMTPDebug = 0; 

//Ask for HTML-friendly debug output 
$mail->Debugoutput = 'html'; 

// Headers 
$headers = "Content-Type: text/plain; charset=\"utf-8\"\n" 
       . "X-mailer: YOUR_SITE_DOMAIN Server" . "\r\n" // this will identify the real sender 
       . "Precedence: bulk" . "\r\n" // this will say it is bulk sender 
       . "List-Unsubscribe:[email protected]_SITE_DOMAIN\r\n" // this will reveal the OPT-OUT address 
       . "Reply-To: $email\n" 
       . "To: $email\n" 
       . "From: $email\n"; 

$mail->addCustomHeader($headers); 

//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 = 587; 

//Set the encryption system to use - ssl (deprecated) or tls 
$mail->SMTPSecure = 'tls'; 

//Whether to use SMTP authentication 
$mail->SMTPAuth = true; 

//Username to use for SMTP authentication - use full email address for gmail 
$mail->Username = "[email protected]"; 

//Password to use for SMTP authentication 
$mail->Password = "****"; 

// Because html is being used 
$mail->isHTML(true); 

//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'code'); 

//Set an alternative reply-to address 
$mail->addReplyTo('[email protected]', 'code'); 

//Set who the message is to be sent to 
$mail->addAddress($to, 'Customer'); 

//Set the subject line 
$mail->Subject = 'code'; 

$phpMailerText="<!DOCTYPE HTML><html> 
<head> 
<title>HTML email</title> 
</head> 
<body> 

<a href='http://www.companyname.com/changepassword.php?user_id=" .$User_id1."'>Create your password here</a> 
</body> 
</html>"; 

$mail->msgHTML($phpMailerText); 

//Replace the plain text body with one created manually 
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; 

//send the message, check for errors 
if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
} 
+0

Mr.Deanにお返事いただきありがとうございますが、依然として私は同じ問題が発生しています –

+0

このコードはちょうど作成されています。それは単に動作しません。 – Synchro

+0

Mr.Dean、エラーが発生します。Parse error:予期しない構文エラーです。 ' in $ headers –

0

次のコードを使用してhappends何を教えてくださいを作成します。

$mail = new PHPMailer(); // create a new object 
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only 
$mail->SMTPAuth = true; // authentication enabled 
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail 
$mail->Host = "smtp.gmail.com"; 
$mail->Port = 587; 
$mail->IsHTML(true); 
$mail->Username = "[email protected]"; 
$mail->Password = "password"; 
$mail->SetFrom("[email protected]"); 
$mail->Subject = "Test"; 
$mail->Body = "hello"; 
$mail->AddAddress("[email protected]"); 

if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message has been sent"; 
} 
+0

Mr.Dean、[email protected]、[email protected]どちらのメールも同じですか? –

+0

エラーが発生しました。2017-01-04 10:47:39 SMTP注意:接続されているかどうかを確認中にEOFが検出されました。2017-01-04 10:47:39 SMTP connect()が失敗しました。メーラーエラー:SMTP connect()に失敗しました。 –

+0

はい、同じです –

関連する問題