我正在为PHPMailer使用php插件。它的版本是PHPMailer_5.2。4.我已经测试了PhpMailer站点的示例代码。
<?php
require_once('PHPMailer_5.2.4/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
//$body = file_get_contents('contents.html');
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.google.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "myuser@gmail.com"; // GMAIL username
$mail->Password = "mypass"; // GMAIL password
$mail->SetFrom('myuser@gmail.com', 'First Last');
$mail->Subject = "FeedBack";
$mail->MsgHTML("helo hru ");
$address = "whomto@domainname.com";
$mail->AddAddress($address, "MYName");
$mail->Send();
//if(!$mail->Send()) {
////echo "Mailer Error: " . $mail->ErrorInfo;
//}
//else {
//echo "Message sent!";
//}
?>
执行完这段代码后,我得到以下输出。但邮件已在我的收件人邮箱成功接收。但我不想要下面的输出消息。我怎样才能纠正它?
SMTP-
SMTP-
SMTP-
SMTP-
SMTP-
SMTP-
SMTP-
SMTP-
SMTP-
只需删除这行代码:
$mail->SMTPDebug = 2;
它将禁用调试输出。
这只是调试输出。设置$mail-
您的问题是$mail-
设置该值会告诉PHPMailer输出调试数据,这就是您看到的。
删除该行,您将无法再获得输出。