promisify nodemailer-smtp-transport
See original GitHub issueHey, i try to get into bluebird. can you help me with wrapping nodemailer-smtp-transport? I am using koa and tried a lot but couldnt find the solution. Here is my code:
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var Promise = require("bluebird");
exports.create = function*() {
var transporter = nodemailer.createTransport(smtpTransport({
host: 'smtp.myemailservice.de',
port: 25,
auth: {
user: 'user',
pass: 'pw'
}
}));
var mailOptions = {
from: 'Fred Foo ✔ <foo@blurdybloop.com>', // sender address
to: 'email@email.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ✔', // plaintext body
html: 'mail conent'·
};
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
this.body = error;
} else {
this.body = info.response;
}
});
};
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Promisify Nodemailer with bluebird? - Stack Overflow
This how I got it working (typescript, bluebird's Promise, nodemailer-smtp-transport): export const SendEmail = (from:string, to:string[], ...
Read more >SMTP transport - Nodemailer
SMTP transport. SMTP is the main transport in Nodemailer ... You can verify your SMTP configuration with verify(callback) call (also works as a...
Read more >nodemailer-smtp-transport JavaScript and Node.js ... - Tabnine
How to use nodemailer-smtp-transport. Best JavaScript code snippets using nodemailer-smtp-transport(Showing top 8 results out of 315).
Read more >Nodemailer Service in Node.js using SMTP and xoauth2
Here, we will learn how to send a mail in Node.js using Nodemailer ... config')// create reusable transporter object using the default SMTP...
Read more >How to use the nodemailer.createTestAccount function in ...
return new Promise((resolve, reject) => { // Generate test SMTP service account from ethereal.email // Only needed if you don't have a real...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was also having the same problem some time ago. The code above is no longer valid. You have to use this:
Note that if you are trying to use a transport mechanism that is not built-in, there is a small difference. Instead of passing an options object to the
createTransport
method, you pass the external transport directly like so:nodemailer-smtp-transport
is built-in tonodemailer
(it’s the default transport) so you should need to install it separately. I typically only promisify thesendMail
method:However you can promisify all the methods by using
P.promisifyAll
like such:By default, bluebird gives the new promise aware methods
Async
suffixes so you’d use sendMail like this: