Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

nodemailer typescript

//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);
  });
});
 
PREVIOUS NEXT
Tagged: #nodemailer #typescript
ADD COMMENT
Topic
Name
2+7 =