Horje
@sendgrid/mail npm Code Example
sendgrid sdk npm
npm install --save @sendgrid/mail
@sendgrid/mail npm
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
  to: 'test@example.com',
  from: 'test@example.com', // Use the email address or domain you verified above
  subject: 'Sending with Twilio SendGrid is Fun',
  text: 'and easy to do anywhere, even with Node.js',
  html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
//ES6
sgMail
  .send(msg)
  .then(() => {}, error => {
    console.error(error);

    if (error.response) {
      console.error(error.response.body)
    }
  });
//ES8
(async () => {
  try {
    await sgMail.send(msg);
  } catch (error) {
    console.error(error);

    if (error.response) {
      console.error(error.response.body)
    }
  }
})();
npm sendgrid
npm install --save @sendgrid/mail
Source: sendgrid.com




Javascript

Related
jquery select dropdown Code Example jquery select dropdown Code Example
CSS on Javascript Code Example CSS on Javascript Code Example
typescript array find Code Example typescript array find Code Example
Lazy Loading Routes vue Code Example Lazy Loading Routes vue Code Example
js find value in array Code Example js find value in array Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6