如何隐藏PHPMailer的日志?
How to hide the logs of PHPMailer?
我的代码可以工作,但是当我发送电子邮件时,我看到这个长长的信息块是这样开头的:
2021-03-06 13:42:26 CLIENT -> SERVER: EHLO localhost
2021-03-06 13:42:26 CLIENT -> SERVER: STARTTLS
2021-03-06 13:42:27 CLIENT -> SERVER: EHLO localhost
2021-03-06 13:42:27 CLIENT -> SERVER: AUTH LOGIN
2021-03-06 13:42:27 CLIENT -> SERVER: [credentials hidden]
2021-03-06 13:42:27 CLIENT -> SERVER: [credentials hidden]
...并继续编写有关 PHPMailer 的所有信息。
不想让大家发邮件后看到,怎么隐藏?
这是我的代码:
if($errore == 0){
$message_email = 'Messaggio inviato da: '.$name.' '.$surname.'<br>';
$message_email .= 'Email: '.$email.'<br>';
$message_email .= 'Telefono: '.$number.'<br>';
$message_email .= 'Oggetto: '.$object.'<br>';
$message_email .= 'Corpo: '.$message.'<br>';
require 'PHPMailer.php';
require 'Exception.php';
require 'SMTP.php';
$mail = new \PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = "smtp.gmail.com";
$mail->Username = "myemail@gmail.com";
$mail->Password = "mypass";
$mail->IsHTML(true);
$mail->setFrom('bibibibi@gmail.com');
$mail->addAddress('lalala@gmail.com');
$mail->msgHtml($messaggio_email);
$mail->Subject = $object;
if(!$mail->Send()) {
echo "something went wrong";
var_dump($mail);
} else {
echo 'Email sent';
}
您需要更改“SMTP class 调试输出模式。”使用 SMTPDebug
属性.
$mail->SMTPDebug = SMTP::DEBUG_OFF;
你的实际值(1
)对应DEBUG_CLIENT
.
但您应该使用以下允许值之一:
- SMTP::DEBUG_OFF: 无输出
- SMTP::DEBUG_CLIENT:客户端消息
- SMTP::DEBUG_SERVER:客户端和服务器消息
- SMTP::DEBUG_CONNECTION:作为服务器加上连接状态
- SMTP::DEBUG_LOWLEVEL:嘈杂的低级数据输出,很少需要
我的代码可以工作,但是当我发送电子邮件时,我看到这个长长的信息块是这样开头的:
2021-03-06 13:42:26 CLIENT -> SERVER: EHLO localhost
2021-03-06 13:42:26 CLIENT -> SERVER: STARTTLS
2021-03-06 13:42:27 CLIENT -> SERVER: EHLO localhost
2021-03-06 13:42:27 CLIENT -> SERVER: AUTH LOGIN
2021-03-06 13:42:27 CLIENT -> SERVER: [credentials hidden]
2021-03-06 13:42:27 CLIENT -> SERVER: [credentials hidden]
...并继续编写有关 PHPMailer 的所有信息。
不想让大家发邮件后看到,怎么隐藏?
这是我的代码:
if($errore == 0){
$message_email = 'Messaggio inviato da: '.$name.' '.$surname.'<br>';
$message_email .= 'Email: '.$email.'<br>';
$message_email .= 'Telefono: '.$number.'<br>';
$message_email .= 'Oggetto: '.$object.'<br>';
$message_email .= 'Corpo: '.$message.'<br>';
require 'PHPMailer.php';
require 'Exception.php';
require 'SMTP.php';
$mail = new \PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = "smtp.gmail.com";
$mail->Username = "myemail@gmail.com";
$mail->Password = "mypass";
$mail->IsHTML(true);
$mail->setFrom('bibibibi@gmail.com');
$mail->addAddress('lalala@gmail.com');
$mail->msgHtml($messaggio_email);
$mail->Subject = $object;
if(!$mail->Send()) {
echo "something went wrong";
var_dump($mail);
} else {
echo 'Email sent';
}
您需要更改“SMTP class 调试输出模式。”使用 SMTPDebug
属性.
$mail->SMTPDebug = SMTP::DEBUG_OFF;
你的实际值(1
)对应DEBUG_CLIENT
.
但您应该使用以下允许值之一:
- SMTP::DEBUG_OFF: 无输出
- SMTP::DEBUG_CLIENT:客户端消息
- SMTP::DEBUG_SERVER:客户端和服务器消息
- SMTP::DEBUG_CONNECTION:作为服务器加上连接状态
- SMTP::DEBUG_LOWLEVEL:嘈杂的低级数据输出,很少需要