From b0c9bd036bcbf14ad33c7bc18d11d7dfa354e561 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 14:47:48 +0100 Subject: [PATCH 1/7] Feature - Send Test Mail --- .../controller/application/sendtestmail.php | 42 +++++++++++ .../com_config/model/application.php | 35 ++++++++++ .../view/application/tmpl/default_mail.php | 11 +++ .../language/en-GB/en-GB.com_config.ini | 5 ++ media/system/js/sendtestmail.js | 69 +++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 administrator/components/com_config/controller/application/sendtestmail.php create mode 100644 media/system/js/sendtestmail.js diff --git a/administrator/components/com_config/controller/application/sendtestmail.php b/administrator/components/com_config/controller/application/sendtestmail.php new file mode 100644 index 0000000000000..642b6c3f4b7a8 --- /dev/null +++ b/administrator/components/com_config/controller/application/sendtestmail.php @@ -0,0 +1,42 @@ +app->enqueueMessage(JText::_('JINVALID_TOKEN')); + $this->app->redirect('index.php'); + } + + if (!JFactory::getUser()->authorise('core.admin')) + { + $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR')); + $this->app->redirect('index.php'); + } + + $model = new ConfigModelApplication; + $response = new JResponseJson($model->sendTestMail()); + echo $response->__toString(); + JFactory::getApplication()->close(); + } +} diff --git a/administrator/components/com_config/model/application.php b/administrator/components/com_config/model/application.php index fbb0babe49ec9..44148dc7f9a8b 100644 --- a/administrator/components/com_config/model/application.php +++ b/administrator/components/com_config/model/application.php @@ -430,4 +430,39 @@ public function storePermissions($permission) return $e->getMessage(); } } + + + /** + * Method to send a test mail which is called via an AJAX request + * + * @return bool + * @throws Exception + * + * @since 3.6 + */ + public function sendTestMail() + { + // Set the new values to test with the current settings + $conf = JFactory::getConfig(); + $input = JFactory::getApplication()->input; + + $conf->set('smtpauth', $input->get('smtpauth')); + $conf->set('smtpuser', $input->get('smtpuser', '', 'STRING')); + $conf->set('smtppass', $input->get('smtppass', '', 'RAW')); + $conf->set('smtphost', $input->get('smtphost')); + $conf->set('smtpsecure', $input->get('smtpsecure')); + $conf->set('smtpport', $input->get('smtpport')); + $conf->set('mailfrom', $input->get('mailfrom', '', 'STRING')); + $conf->set('fromname', $input->get('fromname', '', 'STRING')); + $conf->set('mailer', $input->get('mailer')); + $conf->set('mailonline', $input->get('mailonline')); + + // Prepare email and send try to send it + $mail_subject = JText::sprintf('COM_CONFIG_SENDMAIL_SUBJECT', $conf->get('sitename')); + $mail_body = JText::_('COM_CONFIG_SENDMAIL_BODY'); + + $send = JFactory::getMailer()->sendMail($conf->get('mailfrom'), $conf->get('fromname'), $conf->get('mailfrom'), $mail_subject, $mail_body); + + return $send === true ? true : false; + } } diff --git a/administrator/components/com_config/view/application/tmpl/default_mail.php b/administrator/components/com_config/view/application/tmpl/default_mail.php index bdfed8d60c827..3d843b3bda7d8 100644 --- a/administrator/components/com_config/view/application/tmpl/default_mail.php +++ b/administrator/components/com_config/view/application/tmpl/default_mail.php @@ -9,6 +9,17 @@ defined('_JEXEC') or die; +JHtml::script('system/sendtestmail.js', false, true); +JFactory::getDocument()->addScriptDeclaration(' + var sendtestmail_url = "' . addslashes(JUri::base()) . 'index.php?option=com_config&task=config.sendtestmail.application&format=json&'.JSession::getFormToken().'=1"; + var success_sendmail = "' . JText::_('COM_CONFIG_SENDMAIL_SUCCESS') . '"; + var error_sendmail = "' . JText::_('COM_CONFIG_SENDMAIL_ERROR') . '"; + '); + $this->name = JText::_('COM_CONFIG_MAIL_SETTINGS'); $this->fieldsname = 'mail'; echo JLayoutHelper::render('joomla.content.options_default', $this); + +echo ''; diff --git a/administrator/language/en-GB/en-GB.com_config.ini b/administrator/language/en-GB/en-GB.com_config.ini index 234e43971f1ec..acc79e232d10e 100644 --- a/administrator/language/en-GB/en-GB.com_config.ini +++ b/administrator/language/en-GB/en-GB.com_config.ini @@ -226,6 +226,11 @@ COM_CONFIG_PERMISSION_SETTINGS="Permission Settings" COM_CONFIG_PERMISSIONS="Permissions" COM_CONFIG_PROXY_SETTINGS="Proxy Settings" COM_CONFIG_SAVE_SUCCESS="Configuration successfully saved." +COM_CONFIG_SENDMAIL_ACTION_BUTTON="Send Test Mail" +COM_CONFIG_SENDMAIL_BODY="This is a test mail. If you receive it, then your email settings are correct!" +COM_CONFIG_SENDMAIL_ERROR="Test mail could not be sent." +COM_CONFIG_SENDMAIL_SUBJECT="Test mail from %s" +COM_CONFIG_SENDMAIL_SUCCESS="Mail sending process executed properly. Additionally, you should check whether you've received the test mail!" COM_CONFIG_SEO_SETTINGS="SEO Settings" COM_CONFIG_SERVER="Server" COM_CONFIG_SERVER_SETTINGS="Server Settings" diff --git a/media/system/js/sendtestmail.js b/media/system/js/sendtestmail.js new file mode 100644 index 0000000000000..3db77ab0e00c7 --- /dev/null +++ b/media/system/js/sendtestmail.js @@ -0,0 +1,69 @@ +/** + * @package Joomla.JavaScript + * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. +* @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +/** + * Calls the sending process of the config class + */ +jQuery(document).ready(function ($) +{ + $('#sendtestmail').click(function () + { + var data = { + smtpauth : $('input[name="jform[smtpauth]"]').val(), + smtpuser : $('input[name="jform[smtpuser]"]').val(), + smtppass : $('input[name="jform[smtppass]"]').val(), + smtphost : $('input[name="jform[smtphost]"]').val(), + smtpsecure: $('select[name="jform[smtpsecure]"]').val(), + smtpport : $('input[name="jform[smtpport]"]').val(), + mailfrom : $('input[name="jform[mailfrom]"]').val(), + fromname : $('input[name="jform[fromname]"]').val(), + mailer : $('select[name="jform[mailer]"]').val(), + mailonline: $('input[name="jform[mailonline]"]:checked').val() + }; + + $.ajax({ + url: sendtestmail_url, + data: data + }) + + .done(function (response) + { + var data = $.parseJSON(response); + var msg = {}; + + if (data.data) + { + msg.success = [success_sendmail]; + } + else + { + msg.error = [error_sendmail]; + + if (typeof data.messages == 'object') + { + if (typeof data.messages.error != 'undefined' && data.messages.error.length > 0) + { + msg.error.push(data.messages.error); + } + + if (typeof data.messages.notice != 'undefined' && data.messages.notice.length > 0) + { + msg.notice = [data.messages.notice] + } + + if (typeof data.messages.message != 'undefined' && data.messages.message.length > 0) + { + msg.message = [data.messages.message]; + } + } + } + + Joomla.renderMessages(msg); + }); + + window.scrollTo(0, 0); + }); +}); From bf8e35135af14c8ebde2ba6992741f0e5837e7a2 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 15:16:50 +0100 Subject: [PATCH 2/7] Code style --- administrator/components/com_config/model/application.php | 1 - media/system/js/sendtestmail.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/administrator/components/com_config/model/application.php b/administrator/components/com_config/model/application.php index 44148dc7f9a8b..5fd1b3d90c1a5 100644 --- a/administrator/components/com_config/model/application.php +++ b/administrator/components/com_config/model/application.php @@ -431,7 +431,6 @@ public function storePermissions($permission) } } - /** * Method to send a test mail which is called via an AJAX request * diff --git a/media/system/js/sendtestmail.js b/media/system/js/sendtestmail.js index 3db77ab0e00c7..4769dd6cb8545 100644 --- a/media/system/js/sendtestmail.js +++ b/media/system/js/sendtestmail.js @@ -1,7 +1,7 @@ /** * @package Joomla.JavaScript * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. -* @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ /** From 52df3058ed44b28cc3392a9da8386b1319b567c6 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 15:30:42 +0100 Subject: [PATCH 3/7] Language improvement --- administrator/language/en-GB/en-GB.com_config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_config.ini b/administrator/language/en-GB/en-GB.com_config.ini index acc79e232d10e..03d4f69bd2be5 100644 --- a/administrator/language/en-GB/en-GB.com_config.ini +++ b/administrator/language/en-GB/en-GB.com_config.ini @@ -230,7 +230,7 @@ COM_CONFIG_SENDMAIL_ACTION_BUTTON="Send Test Mail" COM_CONFIG_SENDMAIL_BODY="This is a test mail. If you receive it, then your email settings are correct!" COM_CONFIG_SENDMAIL_ERROR="Test mail could not be sent." COM_CONFIG_SENDMAIL_SUBJECT="Test mail from %s" -COM_CONFIG_SENDMAIL_SUCCESS="Mail sending process executed properly. Additionally, you should check whether you've received the test mail!" +COM_CONFIG_SENDMAIL_SUCCESS="The email was sent successfully. You should check that you've received the test email." COM_CONFIG_SEO_SETTINGS="SEO Settings" COM_CONFIG_SERVER="Server" COM_CONFIG_SERVER_SETTINGS="Server Settings" From 43ba153677722777e99aebb73e95153e1fd71577 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 17:13:52 +0100 Subject: [PATCH 4/7] More information + Code style --- .../controller/application/sendtestmail.php | 2 + .../com_config/model/application.php | 17 +++++--- .../view/application/tmpl/default_mail.php | 4 +- .../language/en-GB/en-GB.com_config.ini | 7 +++- media/system/js/sendtestmail.js | 39 +++++++++++-------- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/administrator/components/com_config/controller/application/sendtestmail.php b/administrator/components/com_config/controller/application/sendtestmail.php index 642b6c3f4b7a8..c4b1b7fa92471 100644 --- a/administrator/components/com_config/controller/application/sendtestmail.php +++ b/administrator/components/com_config/controller/application/sendtestmail.php @@ -18,6 +18,8 @@ class ConfigControllerApplicationSendtestmail extends JControllerBase /** * Method to send the test mail. * + * @return string + * * @since 3.6 */ public function execute() diff --git a/administrator/components/com_config/model/application.php b/administrator/components/com_config/model/application.php index 5fd1b3d90c1a5..f4f3c83bfd0a4 100644 --- a/administrator/components/com_config/model/application.php +++ b/administrator/components/com_config/model/application.php @@ -435,14 +435,14 @@ public function storePermissions($permission) * Method to send a test mail which is called via an AJAX request * * @return bool - * @throws Exception * * @since 3.6 + * @throws Exception */ public function sendTestMail() { // Set the new values to test with the current settings - $conf = JFactory::getConfig(); + $conf = JFactory::getConfig(); $input = JFactory::getApplication()->input; $conf->set('smtpauth', $input->get('smtpauth')); @@ -458,10 +458,17 @@ public function sendTestMail() // Prepare email and send try to send it $mail_subject = JText::sprintf('COM_CONFIG_SENDMAIL_SUBJECT', $conf->get('sitename')); - $mail_body = JText::_('COM_CONFIG_SENDMAIL_BODY'); + $mail_body = JText::sprintf('COM_CONFIG_SENDMAIL_BODY', JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer')))); + + if (JFactory::getMailer()->sendMail($conf->get('mailfrom'), $conf->get('fromname'), $conf->get('mailfrom'), $mail_subject, $mail_body) === true) + { + JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_CONFIG_SENDMAIL_SUCCESS', $conf->get('mailfrom'), JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer')))), 'success'); + + return true; + } - $send = JFactory::getMailer()->sendMail($conf->get('mailfrom'), $conf->get('fromname'), $conf->get('mailfrom'), $mail_subject, $mail_body); + JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_SENDMAIL_ERROR'), 'error'); - return $send === true ? true : false; + return false; } } diff --git a/administrator/components/com_config/view/application/tmpl/default_mail.php b/administrator/components/com_config/view/application/tmpl/default_mail.php index 3d843b3bda7d8..f070785e3f09c 100644 --- a/administrator/components/com_config/view/application/tmpl/default_mail.php +++ b/administrator/components/com_config/view/application/tmpl/default_mail.php @@ -11,9 +11,7 @@ JHtml::script('system/sendtestmail.js', false, true); JFactory::getDocument()->addScriptDeclaration(' - var sendtestmail_url = "' . addslashes(JUri::base()) . 'index.php?option=com_config&task=config.sendtestmail.application&format=json&'.JSession::getFormToken().'=1"; - var success_sendmail = "' . JText::_('COM_CONFIG_SENDMAIL_SUCCESS') . '"; - var error_sendmail = "' . JText::_('COM_CONFIG_SENDMAIL_ERROR') . '"; + var sendtestmail_url = "' . addslashes(JUri::base()) . 'index.php?option=com_config&task=config.sendtestmail.application&format=json&' . JSession::getFormToken() . '=1"; '); $this->name = JText::_('COM_CONFIG_MAIL_SETTINGS'); diff --git a/administrator/language/en-GB/en-GB.com_config.ini b/administrator/language/en-GB/en-GB.com_config.ini index 03d4f69bd2be5..ef18de4f28c88 100644 --- a/administrator/language/en-GB/en-GB.com_config.ini +++ b/administrator/language/en-GB/en-GB.com_config.ini @@ -227,10 +227,13 @@ COM_CONFIG_PERMISSIONS="Permissions" COM_CONFIG_PROXY_SETTINGS="Proxy Settings" COM_CONFIG_SAVE_SUCCESS="Configuration successfully saved." COM_CONFIG_SENDMAIL_ACTION_BUTTON="Send Test Mail" -COM_CONFIG_SENDMAIL_BODY="This is a test mail. If you receive it, then your email settings are correct!" +COM_CONFIG_SENDMAIL_BODY="This is a test mail sent using "_QQ_"%s"_QQ_". If you receive it, then your email settings are correct!" COM_CONFIG_SENDMAIL_ERROR="Test mail could not be sent." +COM_CONFIG_SENDMAIL_METHOD_MAIL="PHP Mail" +COM_CONFIG_SENDMAIL_METHOD_SENDMAIL="Sendmail" +COM_CONFIG_SENDMAIL_METHOD_SMTP="SMTP" COM_CONFIG_SENDMAIL_SUBJECT="Test mail from %s" -COM_CONFIG_SENDMAIL_SUCCESS="The email was sent successfully. You should check that you've received the test email." +COM_CONFIG_SENDMAIL_SUCCESS="The email was sent successfully to %s using %s. You should check that you've received the test email." COM_CONFIG_SEO_SETTINGS="SEO Settings" COM_CONFIG_SERVER="Server" COM_CONFIG_SERVER_SETTINGS="Server Settings" diff --git a/media/system/js/sendtestmail.js b/media/system/js/sendtestmail.js index 4769dd6cb8545..de473ad714b35 100644 --- a/media/system/js/sendtestmail.js +++ b/media/system/js/sendtestmail.js @@ -1,7 +1,7 @@ /** * @package Joomla.JavaScript * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ /** @@ -11,7 +11,7 @@ jQuery(document).ready(function ($) { $('#sendtestmail').click(function () { - var data = { + var email_data = { smtpauth : $('input[name="jform[smtpauth]"]').val(), smtpuser : $('input[name="jform[smtpuser]"]').val(), smtppass : $('input[name="jform[smtppass]"]').val(), @@ -25,38 +25,43 @@ jQuery(document).ready(function ($) }; $.ajax({ - url: sendtestmail_url, - data: data - }) + url: sendtestmail_url, + data: email_data + }) .done(function (response) { - var data = $.parseJSON(response); + var data_response = $.parseJSON(response); var msg = {}; - if (data.data) + if (data_response.data) { - msg.success = [success_sendmail]; + if (typeof data_response.messages == 'object') + { + if (typeof data_response.messages.success != 'undefined' && data_response.messages.success.length > 0) + { + msg.success = [data_response.messages.success]; + } + } + } else { - msg.error = [error_sendmail]; - - if (typeof data.messages == 'object') + if (typeof data_response.messages == 'object') { - if (typeof data.messages.error != 'undefined' && data.messages.error.length > 0) + if (typeof data_response.messages.error != 'undefined' && data_response.messages.error.length > 0) { - msg.error.push(data.messages.error); + msg.error = [data_response.messages.error]; } - if (typeof data.messages.notice != 'undefined' && data.messages.notice.length > 0) + if (typeof data_response.messages.notice != 'undefined' && data_response.messages.notice.length > 0) { - msg.notice = [data.messages.notice] + msg.notice = [data_response.messages.notice]; } - if (typeof data.messages.message != 'undefined' && data.messages.message.length > 0) + if (typeof data_response.messages.message != 'undefined' && data_response.messages.message.length > 0) { - msg.message = [data.messages.message]; + msg.message = [data_response.messages.message]; } } } From 9e7398b585b3b9f0b98733bd6c6284219251e6d0 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 17:30:15 +0100 Subject: [PATCH 5/7] Travis --- administrator/components/com_config/model/application.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_config/model/application.php b/administrator/components/com_config/model/application.php index f4f3c83bfd0a4..62127423589d8 100644 --- a/administrator/components/com_config/model/application.php +++ b/administrator/components/com_config/model/application.php @@ -462,7 +462,8 @@ public function sendTestMail() if (JFactory::getMailer()->sendMail($conf->get('mailfrom'), $conf->get('fromname'), $conf->get('mailfrom'), $mail_subject, $mail_body) === true) { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_CONFIG_SENDMAIL_SUCCESS', $conf->get('mailfrom'), JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer')))), 'success'); + $method_name = JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer'))); + JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_CONFIG_SENDMAIL_SUCCESS', $conf->get('mailfrom'), $method_name), 'success'); return true; } From a4000f20ff165aad814a0bf982723430da931196 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 17:55:21 +0100 Subject: [PATCH 6/7] $id not available / needed --- .../com_config/view/application/tmpl/default_mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_config/view/application/tmpl/default_mail.php b/administrator/components/com_config/view/application/tmpl/default_mail.php index f070785e3f09c..865f5e6d5704b 100644 --- a/administrator/components/com_config/view/application/tmpl/default_mail.php +++ b/administrator/components/com_config/view/application/tmpl/default_mail.php @@ -18,6 +18,6 @@ $this->fieldsname = 'mail'; echo JLayoutHelper::render('joomla.content.options_default', $this); -echo ''; From bf5ba5ed52522b0cf4ad3ed790400f838e81e571 Mon Sep 17 00:00:00 2001 From: Viktor Vogel Date: Thu, 10 Dec 2015 21:27:37 +0100 Subject: [PATCH 7/7] Code improvements --- .../controller/application/sendtestmail.php | 3 +- .../com_config/model/application.php | 38 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/administrator/components/com_config/controller/application/sendtestmail.php b/administrator/components/com_config/controller/application/sendtestmail.php index c4b1b7fa92471..553933124b428 100644 --- a/administrator/components/com_config/controller/application/sendtestmail.php +++ b/administrator/components/com_config/controller/application/sendtestmail.php @@ -37,8 +37,7 @@ public function execute() } $model = new ConfigModelApplication; - $response = new JResponseJson($model->sendTestMail()); - echo $response->__toString(); + echo new JResponseJson($model->sendTestMail()); JFactory::getApplication()->close(); } } diff --git a/administrator/components/com_config/model/application.php b/administrator/components/com_config/model/application.php index 62127423589d8..d072bd72505fd 100644 --- a/administrator/components/com_config/model/application.php +++ b/administrator/components/com_config/model/application.php @@ -442,33 +442,33 @@ public function storePermissions($permission) public function sendTestMail() { // Set the new values to test with the current settings - $conf = JFactory::getConfig(); - $input = JFactory::getApplication()->input; - - $conf->set('smtpauth', $input->get('smtpauth')); - $conf->set('smtpuser', $input->get('smtpuser', '', 'STRING')); - $conf->set('smtppass', $input->get('smtppass', '', 'RAW')); - $conf->set('smtphost', $input->get('smtphost')); - $conf->set('smtpsecure', $input->get('smtpsecure')); - $conf->set('smtpport', $input->get('smtpport')); - $conf->set('mailfrom', $input->get('mailfrom', '', 'STRING')); - $conf->set('fromname', $input->get('fromname', '', 'STRING')); - $conf->set('mailer', $input->get('mailer')); - $conf->set('mailonline', $input->get('mailonline')); + $app = JFactory::getApplication(); + $input = $app->input; + + $app->set('smtpauth', $input->get('smtpauth')); + $app->set('smtpuser', $input->get('smtpuser', '', 'STRING')); + $app->set('smtppass', $input->get('smtppass', '', 'RAW')); + $app->set('smtphost', $input->get('smtphost')); + $app->set('smtpsecure', $input->get('smtpsecure')); + $app->set('smtpport', $input->get('smtpport')); + $app->set('mailfrom', $input->get('mailfrom', '', 'STRING')); + $app->set('fromname', $input->get('fromname', '', 'STRING')); + $app->set('mailer', $input->get('mailer')); + $app->set('mailonline', $input->get('mailonline')); // Prepare email and send try to send it - $mail_subject = JText::sprintf('COM_CONFIG_SENDMAIL_SUBJECT', $conf->get('sitename')); - $mail_body = JText::sprintf('COM_CONFIG_SENDMAIL_BODY', JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer')))); + $mailSubject = JText::sprintf('COM_CONFIG_SENDMAIL_SUBJECT', $app->get('sitename')); + $mailBody = JText::sprintf('COM_CONFIG_SENDMAIL_BODY', JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($app->get('mailer')))); - if (JFactory::getMailer()->sendMail($conf->get('mailfrom'), $conf->get('fromname'), $conf->get('mailfrom'), $mail_subject, $mail_body) === true) + if (JFactory::getMailer()->sendMail($app->get('mailfrom'), $app->get('fromname'), $app->get('mailfrom'), $mailSubject, $mailBody) === true) { - $method_name = JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($conf->get('mailer'))); - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_CONFIG_SENDMAIL_SUCCESS', $conf->get('mailfrom'), $method_name), 'success'); + $methodName = JText::_('COM_CONFIG_SENDMAIL_METHOD_' . strtoupper($app->get('mailer'))); + $app->enqueueMessage(JText::sprintf('COM_CONFIG_SENDMAIL_SUCCESS', $app->get('mailfrom'), $methodName), 'success'); return true; } - JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_SENDMAIL_ERROR'), 'error'); + $app->enqueueMessage(JText::_('COM_CONFIG_SENDMAIL_ERROR'), 'error'); return false; }