diff --git a/Block/Adminhtml/System/Config/TestButton.php b/Block/Adminhtml/System/Config/ValidateConfigButton.php
similarity index 90%
rename from Block/Adminhtml/System/Config/TestButton.php
rename to Block/Adminhtml/System/Config/ValidateConfigButton.php
index 33c7ab9..cee67d8 100644
--- a/Block/Adminhtml/System/Config/TestButton.php
+++ b/Block/Adminhtml/System/Config/ValidateConfigButton.php
@@ -17,7 +17,7 @@
* "Reset to Defaults" button renderer
*
*/
-class TestButton extends Field
+class ValidateConfigButton extends Field
{
/** @var UrlInterface */
protected $_urlBuilder;
@@ -42,7 +42,7 @@ public function __construct(
protected function _construct()
{
parent::_construct();
- $this->setTemplate('MagePal_GmailSmtpApp::system/config/testbutton.phtml');
+ $this->setTemplate('MagePal_GmailSmtpApp::system/config/validateConfigButton.phtml');
}
/**
@@ -58,8 +58,7 @@ public function getButtonHtml()
)->setData(
[
'id' => 'gmailsmtpapp_debug_result_button',
- 'label' => __('Send Test Email'),
- 'onclick' => 'javascript:gmailSmtpAppDebugTest(); return false;',
+ 'label' => __('Send Test Email')
]
);
@@ -69,7 +68,7 @@ public function getButtonHtml()
public function getAdminUrl()
{
return $this->_urlBuilder->getUrl(
- 'magepalsmtp/testemail',
+ 'magepalsmtp/validateconfig',
['store' => $this->_request->getParam('store')]
);
}
diff --git a/Block/Adminhtml/EmailTest.php b/Block/Adminhtml/ValidateConfig.php
similarity index 99%
rename from Block/Adminhtml/EmailTest.php
rename to Block/Adminhtml/ValidateConfig.php
index f708f86..85fb016 100644
--- a/Block/Adminhtml/EmailTest.php
+++ b/Block/Adminhtml/ValidateConfig.php
@@ -23,7 +23,7 @@
* Class EmailTest
* @package MagePal\GmailSmtpApp\Block\Adminhtml
*/
-class EmailTest extends Template
+class ValidateConfig extends Template
{
/**
* @var Data
diff --git a/Controller/Adminhtml/Testemail/Index.php b/Controller/Adminhtml/Validateconfig/Index.php
similarity index 90%
rename from Controller/Adminhtml/Testemail/Index.php
rename to Controller/Adminhtml/Validateconfig/Index.php
index ae9bb80..65b1328 100644
--- a/Controller/Adminhtml/Testemail/Index.php
+++ b/Controller/Adminhtml/Validateconfig/Index.php
@@ -5,7 +5,7 @@
* http://www.magepal.com | support@magepal.com
*/
-namespace MagePal\GmailSmtpApp\Controller\Adminhtml\Testemail;
+namespace MagePal\GmailSmtpApp\Controller\Adminhtml\Validateconfig;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultFactory;
diff --git a/Model/TwoDotThree/Smtp.php b/Model/TwoDotThree/Smtp.php
index 8ac7390..d0b47c4 100644
--- a/Model/TwoDotThree/Smtp.php
+++ b/Model/TwoDotThree/Smtp.php
@@ -72,15 +72,16 @@ public function setStoreModel(Store $storeModel)
* @param EmailMessageInterface $message
* @throws MailException
*/
- public function sendSmtpMessage(
- EmailMessageInterface $message
- ) {
+ public function sendSmtpMessage(EmailMessageInterface $message)
+ {
$dataHelper = $this->dataHelper;
$dataHelper->setStoreId($this->storeModel->getStoreId());
$encoding = $message->getEncoding();
$message = Message::fromString($message->getRawMessage());
$message->getHeaders()->get('to')->setEncoding('utf-8');
+ $message->getHeaders()->get('reply-to')->setEncoding('utf-8');
+ $message->getHeaders()->get('from')->setEncoding('utf-8');
$message->getHeaders()->setEncoding('utf-8');
$message->setEncoding($encoding);
diff --git a/Model/ZendMailTwo/Smtp.php b/Model/ZendMailTwo/Smtp.php
index db4b91e..bedb2fe 100644
--- a/Model/ZendMailTwo/Smtp.php
+++ b/Model/ZendMailTwo/Smtp.php
@@ -86,6 +86,7 @@ public function sendSmtpMessage(
* Temporary fix since 2.2.x will be deprecated shortly and 2.3.3 uses new logic.
*/
$message = Message::fromString($message->toString());
+ $message->setEncoding('utf-8');
//Set reply-to path
switch ($dataHelper->getConfigSetReturnPath()) {
@@ -176,6 +177,7 @@ public function sendSmtpMessage(
$message->getHeaders()->get('to')->setEncoding('utf-8');
$message->getHeaders()->get('reply-to')->setEncoding('utf-8');
$message->getHeaders()->get('from')->setEncoding('utf-8');
+ $message->getHeaders()->setEncoding('utf-8');
$transport->send($message);
} catch (Exception $e) {
throw new MailException(
diff --git a/composer.json b/composer.json
index abd50a9..c9642c9 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,7 @@
"magento/framework": "100.0.*|100.1.*|101.0.*|102.0.*"
},
"type": "magento2-module",
- "version": "2.7.0",
+ "version": "2.7.1",
"license": [
"proprietary"
],
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 2bbb5d9..3b67afb 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -230,7 +230,7 @@
validate-email
- MagePal\GmailSmtpApp\Block\Adminhtml\System\Config\TestButton
+ MagePal\GmailSmtpApp\Block\Adminhtml\System\Config\ValidateConfigButton
diff --git a/view/adminhtml/layout/magepalsmtp_testemail_index.xml b/view/adminhtml/layout/magepalsmtp_validateconfig_index.xml
similarity index 53%
rename from view/adminhtml/layout/magepalsmtp_testemail_index.xml
rename to view/adminhtml/layout/magepalsmtp_validateconfig_index.xml
index 9dfc6c8..6ee65da 100644
--- a/view/adminhtml/layout/magepalsmtp_testemail_index.xml
+++ b/view/adminhtml/layout/magepalsmtp_validateconfig_index.xml
@@ -1,7 +1,7 @@
-
+
-
\ No newline at end of file
+
diff --git a/view/adminhtml/requirejs-config.js b/view/adminhtml/requirejs-config.js
new file mode 100755
index 0000000..459072f
--- /dev/null
+++ b/view/adminhtml/requirejs-config.js
@@ -0,0 +1,7 @@
+var config = {
+ map: {
+ '*': {
+ magePalGmailSmtpAppValidateConfig: 'MagePal_GmailSmtpApp/js/validate-config'
+ }
+ }
+};
diff --git a/view/adminhtml/templates/system/config/testbutton.phtml b/view/adminhtml/templates/system/config/testbutton.phtml
deleted file mode 100644
index 8e9baaa..0000000
--- a/view/adminhtml/templates/system/config/testbutton.phtml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-getButtonHtml() ?>
diff --git a/view/adminhtml/templates/system/config/validateConfigButton.phtml b/view/adminhtml/templates/system/config/validateConfigButton.phtml
new file mode 100644
index 0000000..95001c2
--- /dev/null
+++ b/view/adminhtml/templates/system/config/validateConfigButton.phtml
@@ -0,0 +1,20 @@
+
+
+
+= $block->getButtonHtml() ?>
+
+
diff --git a/view/adminhtml/templates/emailtest/email.phtml b/view/adminhtml/templates/validateConfig/result.phtml
similarity index 100%
rename from view/adminhtml/templates/emailtest/email.phtml
rename to view/adminhtml/templates/validateConfig/result.phtml
diff --git a/view/adminhtml/web/js/validate-config.js b/view/adminhtml/web/js/validate-config.js
new file mode 100644
index 0000000..c2c9195
--- /dev/null
+++ b/view/adminhtml/web/js/validate-config.js
@@ -0,0 +1,59 @@
+/**
+ * Copyright © MagePal LLC. All rights reserved.
+ * See COPYING.txt for license details.
+ * http://www.magepal.com | support@magepal.com
+ */
+
+define([
+ 'jquery',
+ 'Magento_Ui/js/modal/alert'
+], function ($, alert) {
+
+ var formSubmit = function (config) {
+ var postData = {
+ form_key: FORM_KEY
+ };
+
+ /** global var configForm **/
+ configForm.find('[id^=system_gmailsmtpapp]').find(':input').serializeArray().map(function (field) {
+ var name = field.name.match(/groups\[gmailsmtpapp\]?(\[groups\]\[debug\])?\[fields\]\[(.*)\]\[value]/);
+
+ /**
+ * groups[gmailsmtpapp][groups][debug][fields][email][value]
+ * groups[gmailsmtpapp][fields][password][value]
+ */
+
+ if (name && name.length === 3) {
+ postData[name[2]] = field.value;
+ }
+ });
+
+ $.ajax({
+ url: config.postUrl,
+ type: 'post',
+ dataType: 'html',
+ data: postData,
+ showLoader: true
+ }).done(function (response) {
+ if (typeof response === 'object') {
+ if (response.error) {
+ alert({ title: 'Error', content: response.message });
+ } else if (response.ajaxExpired) {
+ window.location.href = response.ajaxRedirect;
+ }
+ } else {
+ alert({
+ title:'',
+ content:response,
+ buttons: []
+ });
+ }
+ });
+ };
+
+ return function (config) {
+ $('#gmailsmtpapp_debug_result_button').on('click', function () {
+ formSubmit(config);
+ });
+ }
+});