2017-08-16 43 views
0

smtp進程消息不斷顯示在我的頁面上,我想知道如何隱藏它顯示它不顯示當我使用$ mail-> Send())。在php中隱藏smtp進程消息,顯示在頁面上

SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP b45sm276471eda.15 - gsmtp 
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [91.73.223.200] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [91.73.223.200] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
SMTP -> FROM SERVER:250 2.1.0 OK b45sm276471eda.15 - gsmtp 
SMTP -> FROM SERVER:250 2.1.5 OK b45sm276471eda.15 - gsmtp 
SMTP -> FROM SERVER:354 Go ahead b45sm276471eda.15 - gsmtp 
SMTP -> FROM SERVER:250 2.0.0 OK 1502865741 b45sm276471eda.15 - gsmtp 
SMTP -> FROM SERVER:221 2.0.0 closing connection b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [91.73.223.200] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
    SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
    SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [91.73.223.200] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 
    SMTP -> FROM SERVER:250 2.1.0 OK b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER:250 2.1.5 OK b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER:354 Go ahead b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER:250 2.0.0 OK 1502865741 b45sm276471eda.15 - gsmtp 
    SMTP -> FROM SERVER:221 2.0.0 closing connection b45sm276471eda.15 - gsmtp 

這裏是我的代碼

$msg_res = mysqli_query($link, $sql_msg); 
// $row_msg = mysqli_num_rows($msg_res); 

while ($row_res = mysqli_fetch_assoc($msg_res)) { 
    enter code here 
    $ans = $row_res['response']; 
    $qn_code1 = $row_res['qn_code']; 
    $qn_sql = "select qn_txt from survey_questions where qn_code = '$qn_code1';"; 
    $qn_res = mysqli_query($link,$qn_sql); 
    $qn_results = mysqli_fetch_assoc($qn_res); 
    $qn_txt = $qn_results['qn_txt']; 
    $message1.= $qn_txt.":".$ans."<br>"; 
} 



$subject = "$so_num Survey Results - Partner Requested Prompt Feedback"; 
$message = "<p>Please find below the survey questions and the responses from partner &nbsp;&emsp;  :  &emsp;&nbsp; </p> $message1"; 

$mail = new PHPMailer(); 
$mail->IsSMTP(); // set mailer to use SMTP 
$mail->SMTPDebug = 2; 
$mail->SingleTo = true; //will send mail to each email address individually 

$mail->From = "[email protected]"; 
$mail->FromName = "UNHRD Dashboard"; 
$mail->Host = "smtp.gmail.com"; // specify smtp server 
$mail->SMTPSecure = "tls"; // Used instead of SSL when only POP mail is selected 
$mail->Port = 587; // Used instead of 587/465 when only POP mail is selected 
$mail->SMTPAuth = true; 
$mail->Mailer = "smtp"; 
$mail->Username = "[email protected]"; // SMTP username 
$mail->Password = "[email protected]"; // SMTP password 
//$mail->AddAddress("[email protected]");/test 
//$mail->AddAddress("[email protected]"); 
//$mail->AddAddress("[email protected]"); 
$mail->AddAddress("[email protected]"); //test 

$mail->IsHTML(true); 
$mail->Subject =$subject; 
$mail->Body =$message; 


if ($mail->Send()) 
         { 
    echo "<div class='alert alert-fixed'>Message has been sent</div>"; 
} 

else 
{ 
    echo "Message could not be sent."; 
} 
} 

回答

0

啓用了調試信息

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) 
         // 1 = errors and messages 
         // 2 = messages only 

$mail->SMTPDebug = 0; 
+0

它需要爲0才能顯示任何內容。 – ishegg

+0

ow,好的,謝謝,它工作。 –