Sendgrid Email

SendGrid Email

ComeOnOliver Updated 61 repo stars

File contents

SendGrid Email

Setup

npm install @sendgrid/mail

Send Email

import sgMail from '@sendgrid/mail';
sgMail.setApiKey(process.env.SENDGRID_API_KEY);

await sgMail.send({
    to: 'user@example.com',
    from: 'noreply@myapp.com',
    subject: 'Welcome!',
    html: '<h1>Welcome to MyApp</h1><p>Thanks for signing up.</p>',
});

Dynamic Templates

await sgMail.send({
    to: 'user@example.com', from: 'noreply@myapp.com',
    templateId: 'd-xxxx',
    dynamicTemplateData: { name: 'Alice', resetLink: 'https://...' },
});

Bulk Send

await sgMail.sendMultiple({
    to: ['a@b.com', 'c@d.com'], from: 'noreply@app.com',
    subject: 'Newsletter', html: '<p>Monthly update</p>',
});

Webhooks for delivery tracking: delivered, opened, clicked, bounced

ComeOnOliver/skillshub/tree/main/skills/skillshub-team/catalog-batch5/sendgrid-email commit 703ccb948c

Frequently asked questions

npx skillmds@latest add comeonoliver/sendgrid-email