【发布时间】:2014-05-20 09:40:17
【问题描述】:
所以我在我的注册页面上使用了 phpmailer,并且我能够成功发送一封电子邮件,问题是每次成功运行后,这些大量文本一直出现在页面底部。我不能在这里发布全文,因为我认为它包含我认为的私人信息..
但这些消息的每一行都以 SERVER -> CLIENT 开头(然后是 ip、电子邮件和其他随机内容) 知道它是什么以及如何不显示它吗?
用于phpmailer的代码:
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require 'lib/mailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//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 = "---";
//Password to use for SMTP authentication
$mail->Password = "---";
//Set who the message is to be sent from
$mail->setFrom('----', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('', 'First Last');
//Set who the message is to be sent to
$mail->addAddress("$email", "$firstname");
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: ";
} else {
echo "Message sent!";
}
}
}
【问题讨论】:
-
如果您希望我们对某些未知文本发表评论,您将不得不想办法发布其中的一些内容。
-
修改 $mail->SMTPDebug = 2;到 $mail->SMTPDebug = 0;当您的调试正在进行时,消息正在显示。
标签: php forms email text phpmailer