//Example with Sendgrid
const nodemailer = require('nodemailer');
const sendgridTransport = require('nodemailer-sendgrid-transport');
const transporter = nodemailer.createTransport(sendgridTransport({
auth: {
api_key: '<your-API-key>'
}
}));
app.post('/api/mail', () => {
transporter.sendMail({
to: 'example@mail.com',
from: 'test@test.com',
subject: 'Test',
html: '<h1>Success</h1>'
})
.catch(err => {
console.log(err);
});
});