If you have issues with SMTP emails, you can get Joomla to record all the detailed messages exchanged with your SMTP server.  Inspecting the low level transaction log often allows you to see what is going on between the two servers and resolve any connectivity issues with your IT or hosting provider.  This custom method is quite simple to set up if you have FTP or SSH access to the Joomla folder in your web server.

This SMTP debug option involves a temporary modification to a file in the JMail class, an extension of the PHPMailer library. Warning: core modifications are not recommended and you should revert the file back to the original version as soon as possible.

First make a backup copy of the file your are going to modify, libraries/joomla/mail/mail.php.  Then edit this file, mail.php, and add the following lines to the beginning of the function useSMTP(), after line 634:

// 20170221 SMTP log
$this->SMTPDebug = 4; // maximum level data output
// $this->Debugoutput = 'error_log'; // use the PHP error log, as configured in php.ini
$this->Debugoutput = function($message, $level) { $file = 'mail_log.txt'; $config = JFactory::getConfig(); $logfile = $config['log_path'] . '/' . $file;
$log = fopen($logfile, 'a'); fwrite ($log, $message); fclose($log);};
// 20170221 end

After you click the button Send Test Mail in the Global Configuration or any other mail function, you can download the file 'mail_log.txt' from the Joomla log folder, usually administrator/logs.  

Remember to restore the original version of the file mail.php before the log file grows too much.

And here is the way you can log the mail debug entries by using the standard debug option.  Configure the plugin 'System - Debug' with the following key settings:

  • Allowed Groups: Super Users
  • Log Priorities:  All
  • Log Categories: mail
  • Log Almost Everything

Turn on the debug option in Global Configuration and you can find all the details of the SMTP connection requests and responses with error codes from the file administrator/logs/everything.php.