JFACTORY-GETMAILER-001
JFactory::getMailer()
Factory::getMailer()
getMailer() is deprecated since 4.4. Mail is a container service. Exceptions now bubble — wrap send() in try/catch.
JFactory::getMailer() → Mailer from the container
What you will see
- Factory::getMailer is deprecated
Symptoms people search
mail send fatal instead of silent fail
Replace this code
Swap JFactory::getMailer() for Mailer from the container.
Joomla 3
Remove or stop calling this
$mailer = JFactory::getMailer();Joomla 4 / 6
Use this instead
$mailer = Factory::getContainer()->get(\Joomla\CMS\Mail\MailerFactoryInterface::class)->createMailer();How to fix it
- 1Resolve the mailer from the container.
- 2Catch MailDisabledException.
Also known as
getMailer
Related issues
- Joomla 3 → 4Joomla API
JRequest::getVar() and the whole JRequest API
JRequest::getVar() → $app->getInput()->get('id')
- Joomla 3 → 4Joomla API
JError / JException
JError::raiseError() → throw new RuntimeException() / try-catch
- Joomla 3 → 4Joomla API
isAdmin() / isSite()
$app->isAdmin() → $app->isClient('administrator') / isClient('site')
- Joomla 3 → 4Joomla API
Factory::getUri()
JFactory::getUri() → Uri::getInstance()
- Joomla 3 → 4Joomla API
Factory::getXml() / JXMLElement
JFactory::getXML() → SimpleXMLElement
- Joomla 3 → 4Joomla API
Factory::getEditor()
JFactory::getEditor() → Editor::getInstance()