Open kpturner opened 8 years ago
@kpturner - You can just create your own transporter object and pass it directly in using the transporter
configuration option.
// config/email.js
var nodemailer = require('nodemailer');
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'gmail.user@gmail.com',
pass: 'userpass'
}
});
transporter.use('stream', require('nodemailer-dkim').signer({
domainName: 'kreata.ee',
keySelector: 'test',
privateKey: fs.readFileSync('private.pem')
}));
module.exports.email = {
transporter: transporter
};
Perfect - thanks
Actually I spoke too soon. That isn't quite what I need because, unless I am wrong, that involves me knowing that I need to use DKIM when Sails lifts. In my case, I want sails-hook-email to initialise as it normally would. Later on, at runtime as the email is sent, I need to make a programmatic decision whether or not to use DKIM based on some DB config. So I need to be able to influence the transporter after it has been initialised and I need to be able to switch DKIM on/off for each email.
For my simplistic brain I simply added a method to sails-hook-email:
**
* Transporter.
* @return {Object}
*/
transporter: function () {
return transport;
}
then when I came to send the email:
sails.hooks.email.transporter().use('stream', require('nodemailer-dkim').signer({
domainName: 'kreata.ee',
keySelector: 'test',
privateKey: fs.readFileSync('private.pem')
}));
Is there any chance of including the extra method in the plug-in - or is there a better solution?
apply this commit, pls.
Hi
I use sails-hook-email successfully but I am getting some SPAM issues (especially with Hotmail) and want to make use of the nodemailer-dkim plugin. However, I am struggling to find the best way to do this.
I need to be able to tell the transporter to use the plug-in signer like so
but I don't get access transport object that sails-hook-email creates internally