A client called today lamenting that our automated mail (they fill a form and we mail them a code) is not working.

Of course, this is because my code still has the JFactory class and is looking for...

require ('libraries/joomla/factory.php');

...which is no more since Joomla 3.8

I have seen this answer to a similar problem, but getMailer is not named in the linked Github file.

What should I use instead of the following lines?

require ('libraries/joomla/factory.php'); #I suppose nothing
$mail = JFactory::getMailer(); #I have no idea

Of course I'm instantiating the $mail object with everything needed to use


So if that won't work anymore I'd appreciate some guidance.

  • Welcome to JSE. Are you trying to load JFactory outside of Joomla? Are you getting any errors?
    – Lodder
    Oct 5 '17 at 10:42

I looked for JFactory instead of looking for getMailer or factory.php in the class conversion chart mentioned in the answer linked in the question and solved this problem myself:

$mail = \joomla\CMS\factory::getMailer();

Require is not... required anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.