If you want to troubleshoot the SMTP connection to your outgoing mail server, you can do that by setting the existing debug option in the PHPMailer library, which executes the mail functions in Joomla.  This allows you to log the data, mail commands and the connection status to the PHP error log.

Please note that core modifications are not recommended and the following instructions assume that you revert the file to the original version as soon as possible.

These instruction are for Joomla 3.4.8.  If you already run Joomla 3.5.0, follow these instructions instead:  Debugging SMTP Mail in Joomla 3.5.0

Edit the file libraries/joomla/mail/mail.php and add the following lines to the beginning of the function useSmtp(), after line 467:

      // debug SMTPmailer
      // $this->SMTPDebug    = 3;        // output data, commands and connection status
      $this->SMTPDebug    = 4;           // low level data output, all messages
      $this->Debugoutput   = 'error_log';   // output to error log as configured in php.ini

In Joomla 3.4.8 you need to modify also the file libraries/vendor/phpmailer/phpmailer/class.smtp.php and replace line 190 with these lines:

        // if (is_callable($this->Debugoutput)) {
      // Avoid clash with built-in function names
        if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {

Once you run the mail function, for example by using Mass Mail to a small group of test users including yourself, you can see detailed messages in the PHP error log, for example this failed connection:

[19-Mar-2016 10:47:39 Europe/London] Connection: opening to smtp.gmail.com:587, timeout=10, options=array (  )

[19-Mar-2016 10:47:49 Europe/London]SMTP ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

If the SMTP server responds and the connection succeeds, you can see the whole SMTP dialogue in the log file:

[23-Mar-2016 12:47:52 Europe/London] Connection: opening to smtp.gmail.com:587, timeout=300, options=array (  )

[23-Mar-2016 12:47:52 Europe/London] Connection: opened

[23-Mar-2016 12:47:52 Europe/London] SMTP -> get_lines(): $data is ""

[23-Mar-2016 12:47:52 Europe/London] SMTP -> get_lines(): $str is  "220 smtp.gmail.com ESMTP t7z282442970wjf - gsmtp

Make sure that you go back to the original version of the file mail.php before the log file starts growing unnecessarily.

Joomla 3.0.0 was released on 27 September 2012.  It was even easier to install than previous versions on the local workstation, using the Wampserver bundle from http://wampserver.com/en.  I installed it on my remote server using the installation tool of the hosting provider.  Everything went well. I installed reCAPTCHA and read the story about it at http://www.google.com/recaptcha.  Taking part in the effort to OCR books is a contribution to the science, similar to the screensaver I was using several PC generations ago when it ran the SETI application. Berkeley University is still running that program.

Then I wanted to see if Joomla 2.5 templates would work on 3.0 and installed one.  Big mistake - fatal errors happened both at the front end and the back end.   Back to LTS version 2.5.7.

The Joomla 3.x Control Panel shows a list of users who were active at the site, at the front end or the back end.  

logged in before

The data is displayed by a module called Logged-in Users.  In previous versions of Joomla the time of the last activity was also displayed for each user, which was useful.  In version 3.x only the date is included.  If you want to add the time back to the listing, it can be done easily in a template override.  Here are brief instructions how to do that in Joomla 3.4.3, using the Isis administration template.

Copy the file administrator/modules/mod_logged/tmpl/default.php to administrator/templates/isis/html/mod_logged and edit line 44 there:
<span class="icon-calendar"></span> <?php echo JHtml::_('date', $user->time, JText::_('DATE_FORMAT_LC4')); ?>
Replace with this version:
<span class="icon-calendar"></span> <?php echo JHtml::_('date', $user->time, 'Y-m-d H:i'); ?>
logged in after

If you do not want to hard code the date & time format into the layout, you can define your own format as a language constant in the Language Manager - Overrides.

Subsequent Joomla updates will not overwrite the override code but you need to maintain it, should something change in the core code.

The alpha version of Joomla 3.2.0 is now available.  As usual, it is easy to install and it has new features.  

There was something I had wanted to test for some time: Gmail as the SMTP server. The Joomla documentation has instructions how to configure the mail settings but when I first tried it, the connection failed. I decided to configure the good old Telnet into my Windows machine so that I could test the SMTP connection manually. The TCP port 465 of the Gmail server responded, therefore the problem was somewhere else.

It occurred to me that I had started to use Google's 2-step authentication because I accessed Gmail from my Nokia Lumia phone. After the 2-step authentication was turned off, the problem disappeared and my WAMP server was able to send emails.

The 2-step authentication is an important security measure. When it was turned back on, I had to add a new password in the Gmail account settings and use that password as the application specific password in Joomla. The interesting thing was to realise that even though Google's instructions mention that the validity of the password does not depend on the blank spaces between the groups of four characters in the password, it actually did.  After the spaces were removed, the SMTP connection worked.

The instructions at https://docs.joomla.org have now been updated, based on these test results.

More Articles ...

Page 2 of 3