MAIL-DISABLED-001
JMail::send() returned false
MailDisabledException bubbles
Joomla 3 swallowed mail failure as false. Joomla 4 throws. Uncaught exceptions become a 500 on “send email”.
JMail::send() returned false → try/catch MailDisabledException and RuntimeException
What you will see
- Class "Joomla\CMS\Mail\Exception\MailDisabledException"
- Uncaught PHPMailer
Symptoms people search
mail send 500 · MailDisabledException · ErrorInfo
Replace this code
Swap JMail::send() returned false for try/catch MailDisabledException and RuntimeException.
Joomla 3
Remove or stop calling this
if (!$mailer->Send()) { echo $mailer->ErrorInfo; }Joomla 4 / 6
Use this instead
try {
$mailer->send();
} catch (\Joomla\CMS\Mail\Exception\MailDisabledException $e) {
// Mail off in Global Config
} catch (\PHPMailer\PHPMailer\Exception $e) {
$app->enqueueMessage($e->getMessage(), 'error');
}How to fix it
- 1Wrap send() in try/catch.
- 2Do not read ErrorInfo as the only failure path.
Also known as
MailDisabledException · ErrorInfo · PHPMailer
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()