Reputation: 71
My code works but when I send an Email I see this long block on informations that starts like this:
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]
...and goes on writing al the informations about PHPMailer.
I don't want everyone to see it after they send an Email, how can I hide it?
that's my code:
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 = "[email protected]";
$mail->Password = "mypass";
$mail->IsHTML(true);
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->msgHtml($messaggio_email);
$mail->Subject = $object;
if(!$mail->Send()) {
echo "something went wrong";
var_dump($mail);
} else {
echo 'Email sent';
}
Upvotes: 2
Views: 3325
Reputation: 1
Make sure to put any of following codes in the try { } block to make it work.
$mail->SMTPDebug = SMTP::DEBUG_OFF;
OR
$mail->SMTPDebug = 0;
Upvotes: 0
Reputation: 19779
You need to change the "SMTP class debug output mode." using the SMTPDebug
property.
$mail->SMTPDebug = SMTP::DEBUG_OFF;
Your actual value (1
) corresponding to DEBUG_CLIENT
.
But you should use one of the following allowed values :
Upvotes: 4