Skip to content

Node.js based forum software built for the modern web

feat: automatically enable the SMTP transport option if the SMTP service is changed

Julian Lam4055e3bd1cd7
diff --git a/public/language/en-GB/admin/settings/email.json b/public/language/en-GB/admin/settings/email.json
index e6f92fb8ec..93ffe374f9 100644
--- a/public/language/en-GB/admin/settings/email.json
+++ b/public/language/en-GB/admin/settings/email.json
@@ -13,6 +13,7 @@
"smtp-transport.service-help": "Select a service name above in order to use the known information about it. Alternatively, select "Custom Service" and enter the details below.",
"smtp-transport.gmail-warning1": "If you are using GMail as your email provider, you will have to generate an &quot;App Password&quot; in order for NodeBB to authenticate successfully. You can generate one at the <a href=\"https://myaccount.google.com/apppasswords\">App Passwords <i class=\"fa fa-external-link\"></i></a> page.",
"smtp-transport.gmail-warning2": "For more information about this workaround, <a href=\"https://nodemailer.com/usage/using-gmail/\">please consult this NodeMailer article <i class=\"fa fa-external-link\"></i></a> on the issue. An alternative would be to utilise a third-party emailer plugin such as SendGrid, Mailgun, etc. <a href=\"../extend/plugins\">Browse available plugins here</a>.",
+ "smtp-transport.auto-enable-toast": "It looks like you&apos;re configuring an SMTP transport. We enabled the \"SMTP Transport\" option for you.",
"smtp-transport.host": "SMTP Host",
"smtp-transport.port": "SMTP Port",
"smtp-transport.security": "Connection security",
diff --git a/public/src/admin/settings/email.js b/public/src/admin/settings/email.js
index 20f5d8587d..e1598c2c0b 100644
--- a/public/src/admin/settings/email.js
+++ b/public/src/admin/settings/email.js
@@ -108,6 +108,18 @@ define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function
function handleSmtpServiceChange() {
const isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp';
$('[id="email:smtpTransport:custom-service"]')[isCustom ? 'slideDown' : 'slideUp'](isCustom);
+
+ const enabledEl = document.getElementById('email:smtpTransport:enabled');
+ if (enabledEl) {
+ if (!enabledEl.checked) {
+ enabledEl.closest('label').classList.toggle('is-checked', true);
+ enabledEl.checked = true;
+ alerts.alert({
+ message: '[[admin/settings/email:smtp-transport.auto-enable-toast]]',
+ timeout: 5000,
+ });
+ }
+ }
}
return module;