Skip to content

Commit

Permalink
fix: removed invalid options for the sendmail transport (#8576)
Browse files Browse the repository at this point in the history
* Removed invalid options for the sendmail transport that were causing Nodemailer to return the SMTPTransport instead.

* Removed options for rate limiting in admin email interface. Added new option for toggling whether to use pooled connections.
  • Loading branch information
kylefarris committed Aug 26, 2020
1 parent 6e805c1 commit 2b78562
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
3 changes: 1 addition & 2 deletions install/data/defaults.json
Expand Up @@ -110,8 +110,7 @@
"maximumInvites": 0,
"username:disableEdit": 0,
"email:disableEdit": 0,
"email:sendmail:rateLimit": 2,
"email:sendmail:rateDelta": 1000,
"email:smtpTransport:pool": false,
"hideFullname": 0,
"hideEmail": 0,
"allowGuestHandles": 0,
Expand Down
7 changes: 3 additions & 4 deletions public/language/en-GB/admin/settings/email.json
Expand Up @@ -4,10 +4,7 @@
"address-help": "The following email address refers to the email that the recipient will see in the \"From\" and \"Reply To\" fields.",
"from": "From Name",
"from-help": "The from name to display in the email.",
"sendmail-rate-limit": "Send <em>X</em> emails...",
"sendmail-rate-delta": "... every <em>X</em> milliseconds",
"sendmail-rate-help": "Instructs the NodeBB mailer to limit the number of messages sent at once in order to not overwhelm email receiving services. These options do not apply if SMTP Transport is enabled (below).",


"smtp-transport": "SMTP Transport",
"smtp-transport.enabled": "Use an external email server to send emails",
"smtp-transport-help": "You can select from a list of well-known services or enter a custom one.",
Expand All @@ -25,6 +22,8 @@
"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.password": "Password",
"smtp-transport.pool": "Enable pooled connections",
"smtp-transport.pool-help": "Pooling connections prevents NodeBB from creating a new connection for every email. This option only applies if SMTP Transport is enabled.",

"template": "Edit Email Template",
"template.select": "Select Email Template",
Expand Down
7 changes: 3 additions & 4 deletions src/emailer.js
Expand Up @@ -25,9 +25,6 @@ Emailer.transports = {
sendmail: nodemailer.createTransport({
sendmail: true,
newline: 'unix',
pool: true,
rateLimit: meta.config['email:sendmail:rateLimit'],
rateDelta: meta.config['email:sendmail:rateDelta'],
}),
smtp: undefined,
};
Expand Down Expand Up @@ -66,7 +63,9 @@ Emailer.setupFallbackTransport = function (config) {
winston.verbose('[emailer] Setting up SMTP fallback transport');
// Enable Gmail transport if enabled in ACP
if (parseInt(config['email:smtpTransport:enabled'], 10) === 1) {
var smtpOptions = {};
var smtpOptions = {
pool: config['email:smtpTransport:pool'],
};

if (config['email:smtpTransport:user'] || config['email:smtpTransport:pass']) {
smtpOptions.auth = {
Expand Down
24 changes: 11 additions & 13 deletions src/views/admin/settings/email.tpl
Expand Up @@ -18,19 +18,6 @@
</p>
<input type="text" class="form-control input-lg" id="email:from_name" data-field="email:from_name" placeholder="NodeBB" /><br />
</div>
<div class="row">
<div class="form-group col-sm-6">
<label for="email:sendmail:rateLimit">[[admin/settings/email:sendmail-rate-limit]]</label>
<input type="number" data-field="email:sendmail:rateLimit" id="email:sendmail:rateLimit" class="form-control" placeholder="2" />
</div>
<div class="form-group col-sm-6">
<label for="email:sendmail:rateDelta">[[admin/settings/email:sendmail-rate-delta]]</label>
<input type="number" data-field="email:sendmail:rateDelta" id="email:sendmail:rateDelta" class="form-control" placeholder="1000" />
</div>
<p class="col-xs-12 help-block">
[[admin/settings/email:sendmail-rate-help]]
</p>
</div>
</form>
</div>
</div>
Expand All @@ -50,6 +37,17 @@
<span class="mdl-switch__label">[[admin/settings/email:smtp-transport.enabled]]</span>
</label>
</div>
<div class="form-group">
<div class="checkbox">
<label for="email:smtpTransport:pool" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" id="email:smtpTransport:pool" data-field="email:smtpTransport:pool" name="email:smtpTransport:pool" />
<span class="mdl-switch__label">[[admin/settings/email:smtp-transport.pool]]</span>
</label>
</div>
<p class="col-xs-12 help-block">
[[admin/settings/email:smtp-transport.pool-help]]
</p>
</div>
<div class="form-group">
<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">
Expand Down

0 comments on commit 2b78562

Please sign in to comment.