phpmailerHow do I view the log for my PHPMailer emails?
To view the log for PHPMailer emails, you can use the $mail->SMTPDebug
property. This property can be set to one of four values: 0 (no output), 1 (errors and messages), 2 (messages only), or 3 (verbose debug output).
For example, to view verbose debug output, you can use the following code:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
// other settings
$mail->send();
echo "Message sent!";
?>
This will output something like the following:
SERVER -> CLIENT: 220 smtp.example.com ESMTP Postfix
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.example.com
SERVER -> CLIENT: 250-PIPELINING
SERVER -> CLIENT: 250-SIZE 10240000
SERVER -> CLIENT: 250-VRFY
SERVER -> CLIENT: 250-ETRN
SERVER -> CLIENT: 250-STARTTLS
SERVER -> CLIENT: 250-ENHANCEDSTATUSCODES
SERVER -> CLIENT: 250-8BITMIME
SERVER -> CLIENT: 250 DSN
The $mail->SMTPDebug
property is set to 3
by default. It can be set to any of the four values before the $mail->send()
method is called.
Helpful links
More of Phpmailer
- How do I use PHPMailer to attach a ZIP file?
- How can I configure PHPMailer to support Polish characters?
- How can I use PHPMailer in PHP 8?
- How can I use PHPMailer with XAMPP on a localhost?
- How do I configure PHPMailer to use a proxy?
- How do I use autoload.php with PHPMailer?
- How can I use PHPMailer in Yii 1?
- How can I use PHPMailer without SMTP secure?
- How do I set the X-Mailer header using PHPMailer?
See more codes...