Smtp emailer issue 5951 (#5954)

* Fixed typo at emailer.js line 66 (serice -> service)

* When custom SMTP user and password is empty no authentication is attempted

* Added options to choose custom smtp connection security

* Made custom smtp connection security strings translatable

* Changed switch to if-else for custom smtp security option

* Fixed emailer.js lint errors

* Move custom setting to top of list
v1.18.x
Dravere 7 years ago committed by Barış Soner Uşaklı
parent dd5651b859
commit 38900a9964

@ -15,6 +15,10 @@
"smtp-transport.gmail-warning2": "For more information about this workaround, <a href=\"https://nodemailer.com/usage/using-gmail/\">please consult this NodeMailer article on the issue.</a> An alternative would be to utilise a third-party emailer plugin such as SendGrid, Mailgun, etc. <a href=\"{config.relative_path}/admin/extend/plugins\">Browse available plugins here</a>.", "smtp-transport.gmail-warning2": "For more information about this workaround, <a href=\"https://nodemailer.com/usage/using-gmail/\">please consult this NodeMailer article on the issue.</a> An alternative would be to utilise a third-party emailer plugin such as SendGrid, Mailgun, etc. <a href=\"{config.relative_path}/admin/extend/plugins\">Browse available plugins here</a>.",
"smtp-transport.host": "SMTP Host", "smtp-transport.host": "SMTP Host",
"smtp-transport.port": "SMTP Port", "smtp-transport.port": "SMTP Port",
"smtp-transport.security": "Connection security",
"smtp-transport.security-encrypted": "Encrypted",
"smtp-transport.security-starttls": "StartTLS",
"smtp-transport.security-none": "None",
"smtp-transport.username": "Username", "smtp-transport.username": "Username",
"smtp-transport.username-help": "<b>For the Gmail service,</b> enter the full email address here, especially if you are using a Google Apps managed domain.", "smtp-transport.username-help": "<b>For the Gmail service,</b> enter the full email address here, especially if you are using a Google Apps managed domain.",
"smtp-transport.password": "Password", "smtp-transport.password": "Password",

@ -56,17 +56,33 @@ Emailer.registerApp = function (expressApp) {
// Enable Gmail transport if enabled in ACP // Enable Gmail transport if enabled in ACP
if (parseInt(meta.config['email:smtpTransport:enabled'], 10) === 1) { if (parseInt(meta.config['email:smtpTransport:enabled'], 10) === 1) {
var smtpOptions = { var smtpOptions = {};
auth: {
if (meta.config['email:smtpTransport:user'] || meta.config['email:smtpTransport:pass']) {
smtpOptions.auth = {
user: meta.config['email:smtpTransport:user'], user: meta.config['email:smtpTransport:user'],
pass: meta.config['email:smtpTransport:pass'], pass: meta.config['email:smtpTransport:pass'],
}, };
}; }
if (meta.config['email:smtpTransport:serice'] === 'nodebb-custom-smtp') { if (meta.config['email:smtpTransport:service'] === 'nodebb-custom-smtp') {
smtpOptions.port = meta.config['email:smtpTransport:port']; smtpOptions.port = meta.config['email:smtpTransport:port'];
smtpOptions.host = meta.config['email:smtpTransport:host']; smtpOptions.host = meta.config['email:smtpTransport:host'];
smtpOptions.secure = true;
if (meta.config['email:smtpTransport:security'] === 'NONE') {
smtpOptions.secure = false;
smtpOptions.requireTLS = false;
smtpOptions.ignoreTLS = true;
} else if (meta.config['email:smtpTransport:security'] === 'STARTTLS') {
smtpOptions.secure = false;
smtpOptions.requireTLS = true;
smtpOptions.ignoreTLS = false;
} else {
// meta.config['email:smtpTransport:security'] === 'ENCRYPTED' or undefined
smtpOptions.secure = true;
smtpOptions.requireTLS = true;
smtpOptions.ignoreTLS = false;
}
} else { } else {
smtpOptions.service = meta.config['email:smtpTransport:service']; smtpOptions.service = meta.config['email:smtpTransport:service'];
} }

@ -40,12 +40,12 @@
<div class="form-group"> <div class="form-group">
<label for="email:smtpTransport:service"><strong>[[admin/settings/email:smtp-transport.service]]</strong></label> <label for="email:smtpTransport:service"><strong>[[admin/settings/email:smtp-transport.service]]</strong></label>
<select class="form-control input-lg" id="email:smtpTransport:service" data-field="email:smtpTransport:service"> <select class="form-control input-lg" id="email:smtpTransport:service" data-field="email:smtpTransport:service">
<option value="nodebb-custom-smtp" style="font-weight: bold">[[admin/settings/email:smtp-transport.service-custom]]</option>
<option style="font-size: 10px" disabled>&nbsp;</option>
<!-- BEGIN services --> <!-- BEGIN services -->
<option value="@value">@value</option> <option value="@value">@value</option>
<!-- END services --> <!-- END services -->
<option style="font-size: 10px" disabled>&nbsp;</option>
<option value="nodebb-custom-smtp" style="font-weight: bold">[[admin/settings/email:smtp-transport.service-custom]]</option>
</select> </select>
<p class="help-block"> <p class="help-block">
[[admin/settings/email:smtp-transport.service-help]] [[admin/settings/email:smtp-transport.service-help]]
@ -63,6 +63,13 @@
<label for="email:smtpTransport:port">[[admin/settings/email:smtp-transport.port]]</label> <label for="email:smtpTransport:port">[[admin/settings/email:smtp-transport.port]]</label>
<input type="text" class="form-control input-md" id="email:smtpTransport:port" data-field="email:smtpTransport:port" placeholder="5555"> <input type="text" class="form-control input-md" id="email:smtpTransport:port" data-field="email:smtpTransport:port" placeholder="5555">
<label for="email:smtpTransport:security">[[admin/settings/email:smtp-transport.security]]</label>
<select class="form-control" id="email:smtpTransport:security" data-field="email:smtpTransport:security">
<option value="ENCRYPTED">[[admin/settings/email:smtp-transport.security-encrypted]]</option>
<option value="STARTTLS">[[admin/settings/email:smtp-transport.security-starttls]]</option>
<option value="NONE">[[admin/settings/email:smtp-transport.security-none]]</option>
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="email:smtpTransport:user"><strong>[[admin/settings/email:smtp-transport.username]]</strong></label> <label for="email:smtpTransport:user"><strong>[[admin/settings/email:smtp-transport.username]]</strong></label>
@ -136,4 +143,4 @@
</div> </div>
</div> </div>
<!-- IMPORT admin/partials/settings/footer.tpl --> <!-- IMPORT admin/partials/settings/footer.tpl -->

Loading…
Cancel
Save