Last active
August 20, 2019 08:28
-
-
Save rimiti/5334e74b5231a5089d9aa63e0eb4afc2 to your computer and use it in GitHub Desktop.
Sending an email with Mandrill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodemailer = require("nodemailer"); | |
const mandrillTransport = require('nodemailer-mandrill-transport'); | |
const smtpTransport = nodemailer.createTransport(mandrillTransport({ | |
auth: { | |
apiKey : 'your-token' | |
} | |
})); | |
const mailData = { | |
from : '[email protected]', | |
to : '[email protected]', | |
subject : "Test", | |
html : "Hello<br> How are you doing?" | |
}; | |
smtpTransport.sendMail(mailData, function(error, response){ | |
if(error) { | |
throw new Error("Error in sending email"); | |
} | |
console.log("Message sent: " + JSON.stringify(response)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment