Not sure
Mail instance is returned
Error "Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned" happens
Joomla 4.4.0
This has been reported on several pages:
https://www.hikashop.com/forum/install-update/907149-problems-after-joomla-4-4-upgrade.html#355958
https://forum.joomla.org/viewtopic.php?f=812&p=3704289
https://joomla.stackexchange.com/questions/33416/error-when-upgrading-from-4-3-4-5o-4-4-error-meesage
https://forum.joomla.org/viewtopic.php?f=808&p=3704236
Example of callstack:
1 () JROOT/libraries/src/Mail/MailerFactory.php:106
2 Joomla\CMS\Mail\MailerFactory->createMailer() JROOT/libraries/src/Factory.php:708
3 Joomla\CMS\Factory::createMailer() JROOT/libraries/src/Factory.php:490
4 Joomla\CMS\Factory::getMailer() JROOT/components/com_hikashop/controllers/product.php:257
5 productController->add_waitlist() JROOT/libraries/src/MVC/Controller/BaseController.php:693
6 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/administrator/components/com_hikashop/helpers/helper.php:2535
7 hikashopController->execute() JROOT/components/com_hikashop/hikashop.php:88
8 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
9 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
10 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
12 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
13 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
14 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
15 require_once() JROOT/index.php:32
Labels |
Added:
No Code Attached Yet
|
Title |
|
Also 'Send Test Mail' fails:
#
#Date: 2023-10-19 06:43:38 UTC
#Software: Joomla! 4.4.0 Stable [ Pamoja ] 17-October-2023 16:00 GMT
#Fields: datetime priority clientip category message
2023-10-19T06:43:38+00:00 CRITICAL 2003:fe:4705:9d0b:a450:7dd4:404d:cf66 error Uncaught Throwable of type TypeError thrown with message "Joomla\CMS\Mail\MailerFactory::createMailer(): Return value must be of type Joomla\CMS\Mail\MailerInterface, Joomla\CMS\Mail\Mail returned". Stack trace: #0 [ROOT]/administrator/components/com_config/src/Model/ApplicationModel.php(1201): Joomla\CMS\Mail\MailerFactory->createMailer()
#1 [ROOT]/administrator/components/com_config/src/Controller/ApplicationController.php(270): Joomla\Component\Config\Administrator\Model\ApplicationModel->sendTestMail()
#2 [ROOT]/libraries/src/MVC/Controller/BaseController.php(693): Joomla\Component\Config\Administrator\Controller\ApplicationController->sendtestmail()
#3 [ROOT]/libraries/src/Dispatcher/ComponentDispatcher.php(143): Joomla\CMS\MVC\Controller\BaseController->execute()
#4 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()
#5 [ROOT]/libraries/src/Application/AdministratorApplication.php(143): Joomla\CMS\Component\ComponentHelper::renderComponent()
#6 [ROOT]/libraries/src/Application/AdministratorApplication.php(186): Joomla\CMS\Application\AdministratorApplication->dispatch()
#7 [ROOT]/libraries/src/Application/CMSApplication.php(293): Joomla\CMS\Application\AdministratorApplication->doExecute()
#8 [ROOT]/administrator/includes/app.php(61): Joomla\CMS\Application\CMSApplication->execute()
#9 [ROOT]/administrator/index.php(32): require_once('/homepages/19/d...')
#10 {main}
Which mailer are you using?
PHP-Mail
I have a feeling this is caused by a 3rd party plugin overriding the Joomla! Mail class (had it happen before, but now with type hinting it could lead to this error)
$mailer = new Mail((bool) $configuration->get('throw_exceptions', true));
add these lines
$reflection = new \ReflectionClass($mailer);
var_dump($reflection->getName());
var_dump($reflection->getFilename());
die;
Take a look at the browser console - open the XHR request and show us the response.
Great, thank you!!!
I've disabled the plugin "AcyMailing - Override Joomla emails" and now everything works fine again!
closing as it is not from core
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-10-19 09:26:43 |
Closed_By | ⇒ | alikon |
I started to look into it, but I'm not sure what the problem is.
I can see that the createMailer function has been changed with Joomla 4.4.0 and that it is now deprecated and due to be removed in Joomla 6. But I don't see why that error would happen.
The callstack points, it seems to me, at some kind of incompatibility between the createMailer function of Factory in JROOT/libraries/src/Factory.php and the createMailer function of MailerFactory in JROOT/libraries/src/Mail/MailerFactory.php