Home » Categories » Multiple Categories

PHPMailer - Troubleshooting Using Debug Logging

Overview

This KB article explains how you can enable debug logging with the PHPMailer to troubleshoot SMTP mail sending problems.

The PHPMailer is used in Nagios Fusion and Nagios XI for sending emails using SMTP. If your system is configured for Sendmail then this KB article does not apply to you.

 

Enable Debug Logging

To enable debug logging you need to edit the class.phpmailer.php file and define the following:

public $SMTPDebug = 4;

By default the value is set to 0.

The following commands will make that change for you:

Nagios Fusion

cd /usr/local/nagiosfusion/html/includes/utils/phpmailer/
sed -i 's/public \$SMTPDebug.*/public \$SMTPDebug = 4;/g' class.phpmailer.php

Nagios XI

Older OS versions:

cd /usr/local/nagiosxi/html/includes/phpmailer/
sed -i 's/public \$SMTPDebug.*/public \$SMTPDebug = 4;/g' class.phpmailer.php

Newer OS versions: 

To enable debug logging you need to edit the utils-email.inc.php file and define the following:
// $mail->SMTPDebug = 4;
By default the value is commented out. We need to initially uncomment.

cd /usr/local/nagiosxi/html/includes/
sudo sed -i 's|// \$mail->SMTPDebug = 4;|\$mail->SMTPDebug = 4;|' utils-email.inc.php


If the value has previously been uncommented and set to 0 (disabled), use the below command to set the value to 4 (enabled).

sed -i s/'mail->SMTPDebug = 0;'/'mail->SMTPDebug = 4;'/1 /usr/local/nagiosxi/html/includes/utils-email.inc.php

 

 

Proceed to the next section to view the debug output.

 

View Debug Output

To view the debug output you need to send a test email.

Nagios Fusion

Open the Nagios Fusion web interface and navigate to Admin > System Configuration > Email Settings.

Click the Send a Test Email button which will then take you to the Test Email Settings page.

Here you need to click the Sent Test Email button.

 

Nagios XI

Open the Nagios XI web interface and navigate to Admin > System Config > Manage Email Settings.

Click the Send a Test Email button which will then take you to the Test Email Settings page.

Here you need to click the Sent Test Email button.

 

The output generated from the test will be placed as raw text at the top of the page, here is an example:

 

 

You can see in the screenshot above that there was an authentication issue. The output you see on your screen will be different and you can use that output to further troubleshoot your SMTP problems. Please refer to the following link for troubleshooting resources:

Troubleshooting PHPMailer Problems

 

 

Disable Debug Logging

When you no longer require the debug logging you will need to disable it by editing the class.phpmailer.php file and define the following:

public $SMTPDebug = 0;

 

The following commands will make that change for you:

Nagios Fusion

cd /usr/local/nagiosfusion/html/includes/utils/phpmailer/
sed -i 's/public \$SMTPDebug.*/public \$SMTPDebug = 0;/g' class.phpmailer.php

Nagios XI

Older OS versions:

cd /usr/local/nagiosxi/html/includes/phpmailer/
sed -i 's/public \$SMTPDebug.*/public \$SMTPDebug = 0;/g' class.phpmailer.php

Newer OS versions:

cd /usr/local/nagiosxi/html/includes/
sudo sed -i 's|\$mail->SMTPDebug = .*|\$mail->SMTPDebug = 0;|' utils-email.inc.php

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

1.5 (4)
Article Rating (4 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Disabling Outdated Versions of SSL/TLS
Viewed 8674 times since Thu, Aug 6, 2020
Nagios XI - SNMP MIB Upload Problems
Viewed 9540 times since Mon, Apr 10, 2017
Nagios XI - Scheduled Reports Not Running
Viewed 6037 times since Thu, Aug 10, 2017
Nagios XI - Integrating Slack With Nagios XI
Viewed 4468 times since Sun, Jul 9, 2017
Nagios XI - Sending SNMP Traps
Viewed 7955 times since Thu, Jan 28, 2016
Nagios XI - Some BPI Checks Show "Unknown BPI Group Index" After Upgrade
Viewed 4586 times since Wed, Sep 18, 2019
Nagios XI - Configuration Applies, but still get "Configuration File Is Out Of Date" Error
Viewed 5398 times since Tue, Jan 26, 2016
Nagios Fusion - Multi-Tenancy
Viewed 4033 times since Thu, Jan 21, 2016
API changes in Nagios XI 5.7
Viewed 4096 times since Tue, Feb 23, 2021
Nagios Fusion - Resetting The nagiosadmin Password
Viewed 4585 times since Tue, May 23, 2017