我正在为 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 -> 从服务器:220 mx.google.com ESMTP b3sm40861402pbu.38 - gsmtp
SMTP -> 从服务器:250-mx.google.com 为您服务,[ipAddress] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 CHUNKING
SMTP -> FROM SERVER:220 2.0.0 准备启动 TLS
SMTP -> 从服务器:250-mx.google.com 为您服务,[ipAddress] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250 CHUNKING
SMTP -> 从服务器:250 2.1.0 OK b3sm40861402pbu.38 - gsmtp
SMTP -> 从服务器:250 2.1.5 OK b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:354 继续 b3sm40861402pbu.38 - gsmtp
SMTP -> 从服务器:250 2.0.0 OK 1383737961 b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:221 2.0.0 关闭连接 b3sm40861402pbu.38 - gsmtp