Incompatible w/nodemailer API?
kearygriffin opened this issue · 2 comments
I saw the comments for issue #5 where it mentions that the html, text, subject and from should be part of the "content" object rather than as top level members of the mailOptions object.
However doesn't this actually make the nodemailer-sparkpost transport incompatible with the actual nodemailer API?
This is the example mailOptions given on the nodemailer page:
var mailOptions = {
from: '"Fred Foo 👥" <foo@blurdybloop.com>', // sender address
to: 'bar@blurdybloop.com, baz@blurdybloop.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world 🐴', // plaintext body
html: '<b>Hello world 🐴</b>' // html body
};
From quickly browsing through the other nodemailer transports, it appears they all seem to take the parameters in that format.
Normally I wouldn't worry about this and just change my code to deal with the inconsistency, but I'm using another NPM module (seneca-mail) which internally uses nodemailer, and assumes the standard nodemailer API for all transports.
I just ran into this as well.
The transport object should be agnostic as to what is being sent through it -- by having to specify a template or a content object at transport creation time, it means you'd have to instantiate a new nodemailer transport for each e-mail being sent.
Yup, you're absolutely right - thats not great. Here is Nodemailer's message fields spec. Please watch this issue... ;)