Skip to content

Commit 63beaa2

Browse files
authored
Merge pull request #3004 from strongloop/fix/email-template-in-transport
Remove "options.template" from Email payload
2 parents 7f2cdc1 + 5016703 commit 63beaa2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

common/models/user.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ module.exports = function(User) {
477477
function setHtmlContentAndSend(html) {
478478
options.html = html;
479479

480+
// Remove options.template to prevent rejection by certain
481+
// nodemailer transport plugins.
482+
delete options.template;
483+
480484
Email.send(options, function(err, email) {
481485
if (err) {
482486
fn(err);

test/user.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,24 @@ describe('User', function() {
16681668
done();
16691669
});
16701670
});
1671+
1672+
it('removes "options.template" from Email payload', function() {
1673+
var MailerMock = {
1674+
send: function(options, cb) { cb(null, options); },
1675+
};
1676+
1677+
return User.create({email: '[email protected]', password: 'pass'})
1678+
.then(function(user) {
1679+
return user.verify({
1680+
type: 'email',
1681+
1682+
mailer: MailerMock,
1683+
});
1684+
})
1685+
.then(function(result) {
1686+
expect(result.email).to.not.have.property('template');
1687+
});
1688+
});
16711689
});
16721690

16731691
describe('User.confirm(options, fn)', function() {

0 commit comments

Comments
 (0)