所以我使用phpmailer作为我的注册页面,我能够成功发送电子邮件问题是每次成功运行后,这些大量文本一直出现在页面底部。我不能在这里发布全文,因为我认为它包含我认为的私人信息..
但这些消息的每一行都以SERVER开头 - >客户端(然后是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!";
}
}
}
答案 0 :(得分:0)
转到供应商文件夹,然后是 phpmailer,然后是 src,然后单击 SMTP.php 文件。向下滚动文件并找到 const DEBUG_SERVER=2;将此值从 2 更改为 0。它应该可以工作。