Installing and upgrading help

SMTP PHP debug messages disappear

Picture of Scott Brim
SMTP PHP debug messages disappear

Hi all. I'm pretty new to this, and we are just moving 2.9+ from a test server (in my office, Xubuntu) to a hosted environment. Everything seems good except that I'm having a mail authentication problem (it works fine on my test server). There are two parts to my question. If you can help solve the first, the answer to the second is optional. smile

I'm currently using the PHP mail interface to funnel mail through Google, not the server's mail service -- don't ask why, that would be another two paragraphs. I turn on email debugging under Development and try to send a test user a message, and get lots of PHP output. I mostly manage to keep up, and I see at least one message says "Unable to authenticate at this time", but before I can scroll to the bottom to see all the messages, or ponder what's going on, the debugging messages disappear and I go back to the original web page.

So (1) any ideas based on Google saying "unable to authenticate at this time"?  Remember my SMTP messaging config works just fine on my test server. And (2) any ideas how to keep the PHP debug messages on screen for at least 15 seconds?

Thanks much ... Scott

Average of ratings: -
Picture of Brian King
Re: SMTP PHP debug messages disappear
Core developers
For  (2) any ideas how to keep the PHP debug messages on screen for at least 15 seconds? :

If you got to the Site Administration -> Developer -> Debugging section, you can enable the "Display debug messages" setting.  Once that is enabled, it should disable the automatic redirect.  If that is not enough, try setting the "debug messages" level to "DEVELOPER".

Of course this means that all users will see all the debugging messages everyplace on your Moodle.

In principal, alternatively, instead of setting "display debug messages" and "debug messages", you can set the variable $CFG->debugusers in config.php to a comma-separated list of user ids that should always see the messages.  So if your user id is 99, put this in your config.php:

$CFG->debugusers = '99';

However, testing that on a Moodle 2.7, $CFG->debugusers doesn't work like that.  The only way I could get it to stop before the page redirects was to enable "Display debug messages" and to set "debug messages" to "NORMAL" or higher.

A couple of other possibilities:

* Google Chrome includes a throttling feature.  If you open up the developer tools panel in Chrome, you can change "No throttling" to GPRS.  That should give you enough time to do a quick select-all / copy once the SMTP messages appear, and before the page redirects.  You can then paste that someplace else and read it.

* You can use a tool like Wireshark to capture all the text that has been transmitted.

Average of ratings: Useful (1)
Picture of Brian King
Re: SMTP PHP debug messages disappear
Core developers

One other approach that you can take to debug the SMTP messages, assuming you have access to change the Moodle code, and to read the web server's error logs:

Find the text "$mailer->SMTPDebug = true" in the lib/moodlelib.php file, and change that part to look like this:

if (!empty($CFG->debugsmtp)) {
$mailer->SMTPDebug = true;
$mailer->Debugoutput = "error_log";
(e.g. add the $mailer->Debugoutput line).

You will then see all of phpmailer's debug output in the web server error log, assuming your debugsmtp setting is enabled.  And in this case, it doesn't matter what "Display debug messages" or "Debug messages" are set to; all mailer messages will be sent to the web server's error log.

Average of ratings: Useful (2)