Merge pull request #396 from strongloop/feature/fix-issue-375
Fix for email transports
This commit is contained in:
commit
405d04f4ad
|
@ -59,10 +59,17 @@ MailConnector.prototype.setupTransport = function(setting) {
|
||||||
connector.transports = connector.transports || [];
|
connector.transports = connector.transports || [];
|
||||||
connector.transportsIndex = connector.transportsIndex || {};
|
connector.transportsIndex = connector.transportsIndex || {};
|
||||||
|
|
||||||
var transportModuleName = 'nodemailer-' + (setting.type || 'STUB').toLowerCase() + '-transport';
|
var transport;
|
||||||
var transportModule = require(transportModuleName);
|
var transportType = (setting.type || 'STUB').toLowerCase();
|
||||||
|
if (transportType === 'direct') {
|
||||||
var transport = mailer.createTransport(transportModule(setting));
|
transport = mailer.createTransport();
|
||||||
|
} else if (transportType === 'smtp') {
|
||||||
|
transport = mailer.createTransport(setting);
|
||||||
|
} else {
|
||||||
|
var transportModuleName = 'nodemailer-' + transportType + '-transport';
|
||||||
|
var transportModule = require(transportModuleName);
|
||||||
|
transport = mailer.createTransport(transportModule(setting));
|
||||||
|
}
|
||||||
|
|
||||||
connector.transportsIndex[setting.type] = transport;
|
connector.transportsIndex[setting.type] = transport;
|
||||||
connector.transports.push(transport);
|
connector.transports.push(transport);
|
||||||
|
|
|
@ -1,6 +1,30 @@
|
||||||
var loopback = require('../');
|
var loopback = require('../');
|
||||||
var MyEmail;
|
var MyEmail;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var MailConnector = require('../lib/connectors/mail');
|
||||||
|
|
||||||
|
describe('Email connector', function () {
|
||||||
|
it('should set up SMTP', function () {
|
||||||
|
var connector = new MailConnector({transports: [
|
||||||
|
{type: 'smtp', service: 'gmail'}
|
||||||
|
]});
|
||||||
|
assert(connector.transportForName('smtp'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set up DIRECT', function () {
|
||||||
|
var connector = new MailConnector({transports: [
|
||||||
|
{type: 'direct', name: 'localhost'}
|
||||||
|
]});
|
||||||
|
assert(connector.transportForName('direct'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set up STUB', function () {
|
||||||
|
var connector = new MailConnector({transports: [
|
||||||
|
{type: 'stub', service: 'gmail'}
|
||||||
|
]});
|
||||||
|
assert(connector.transportForName('stub'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Email and SMTP', function () {
|
describe('Email and SMTP', function () {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
Loading…
Reference in New Issue