PHPMailer 发送电子邮件成功后的回显信息

4

你好,我终于让PHPMailer与Google配合正常工作了,但现在发现邮件发送后屏幕上出现了这个输出。

SMTP -> FROM SERVER:220 mx.google.com ESMTP f34sm21891943qco.35
SMTP -> FROM SERVER: 250-mx.google.com at your service, [76.28.109.170] 250-SIZE 35651584 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK f34sm21891943qco.35
SMTP -> FROM SERVER:250 2.1.5 OK f34sm21891943qco.35
SMTP -> FROM SERVER:354 Go ahead f34sm21891943qco.35
SMTP -> FROM SERVER:250 2.0.0 OK 1276700936 f34sm21891943qco.35 

我想知道是否有任何方法可以删除此输出,以便用户看不到它?
2个回答

9

1

<?php

 require("PHPMailer/PHPMailerAutoload.php");

$mail = new PHPMailer;

//Enable SMTP debugging. 3 disable=0
$mail->SMTPDebug = 0;                               

//Set PHPMailer to use SMTP.
$mail->isSMTP();            

//Set SMTP host name                          
$mail->Host = "smtp.gmail.com";//or your domain

//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;                          

//Provide username and password     
$mail->Username = "your email";                 
$mail->Password = "your email password";                           
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";                           
//Set TCP port to connect to 
$mail->Port = 587;                                   

$mail->From = "your email";
$mail->FromName = "your name";

$mail->addAddress($userMail, $uname);

$mail->isHTML(true);

$mail->Subject = $subject;
$mail->Body = $message;
//$mail->AltBody = "This is the plain text version of the email content";

// you can also comment the echos here out
if(!$mail->send()) 
{
    echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
    echo "Message has been sent successfully";
}

?>

输入代码在第8行检查此图像。 您还可以注释掉if(!$mail->send()){ } else{}块 在此输入图片描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接