Using sendmail instead of direct transport

Squashed commit of the following:

commit 9d4937fff6f6a1b4327fed0ada32153bd7e07efd
Author: Julian Lam <julian@designcreateplay.com>
Date:   Mon Jan 18 13:21:52 2016 -0500

    Revert "added some debug code"

    This reverts commit 2dd8535c7bd8f59b8ed59c8b98b5484a79fa0500.

commit 2dd8535c7bd8f59b8ed59c8b98b5484a79fa0500
Author: Julian Lam <julian@designcreateplay.com>
Date:   Mon Jan 18 12:04:02 2016 -0500

    added some debug code

commit af8ca8241e66fd538089517e7722c644668667f2
Author: Julian Lam <julian@designcreateplay.com>
Date:   Mon Jan 18 11:50:41 2016 -0500

    using sendmail instead of direct transport
v1.18.x
Julian Lam 9 years ago
parent 5e22c6dd25
commit 1c2518fe22

@ -55,7 +55,8 @@
"nodebb-theme-persona": "4.0.59", "nodebb-theme-persona": "4.0.59",
"nodebb-theme-vanilla": "5.0.29", "nodebb-theme-vanilla": "5.0.29",
"nodebb-widget-essentials": "2.0.5", "nodebb-widget-essentials": "2.0.5",
"nodemailer": "0.7.1", "nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0",
"passport": "^0.3.0", "passport": "^0.3.0",
"passport-local": "1.0.0", "passport-local": "1.0.0",
"postcss": "^5.0.13", "postcss": "^5.0.13",

@ -5,6 +5,7 @@ var async = require('async'),
nconf = require('nconf'), nconf = require('nconf'),
templates = require('templates.js'), templates = require('templates.js'),
nodemailer = require('nodemailer'), nodemailer = require('nodemailer'),
sendmailTransport = require('nodemailer-sendmail-transport'),
htmlToText = require('html-to-text'), htmlToText = require('html-to-text'),
url = require('url'), url = require('url'),
@ -14,10 +15,10 @@ var async = require('async'),
translator = require('../public/src/modules/translator'), translator = require('../public/src/modules/translator'),
transports = { transports = {
direct: nodemailer.createTransport('direct'), sendmail: nodemailer.createTransport(sendmailTransport()),
gmail: undefined gmail: undefined
}, },
app; app, fallbackTransport;
(function(Emailer) { (function(Emailer) {
Emailer.registerApp = function(expressApp) { Emailer.registerApp = function(expressApp) {
@ -25,13 +26,15 @@ var async = require('async'),
// Enable Gmail transport if enabled in ACP // Enable Gmail transport if enabled in ACP
if (parseInt(meta.config['email:GmailTransport:enabled'], 10) === 1) { if (parseInt(meta.config['email:GmailTransport:enabled'], 10) === 1) {
transports.gmail = nodemailer.createTransport('SMTP', { fallbackTransport = transports.gmail = nodemailer.createTransport('SMTP', {
service: 'Gmail', service: 'Gmail',
auth: { auth: {
user: meta.config['email:GmailTransport:user'], user: meta.config['email:GmailTransport:user'],
pass: meta.config['email:GmailTransport:pass'] pass: meta.config['email:GmailTransport:pass']
} }
}); });
} else {
fallbackTransport = transports.sendmail;
} }
return Emailer; return Emailer;
@ -119,7 +122,7 @@ var async = require('async'),
delete data.from_name; delete data.from_name;
winston.verbose('[emailer] Sending email to uid ' + data.uid); winston.verbose('[emailer] Sending email to uid ' + data.uid);
transports[transports.gmail ? 'gmail' : 'direct'].sendMail(data, callback); fallbackTransport.sendMail(data, callback);
}; };
function render(tpl, params, next) { function render(tpl, params, next) {

Loading…
Cancel
Save