fastify-xemail
SendGrid email integration plugin for transactional and template emails.
fastify-xemail
SendGrid email plugin for sending transactional emails, template emails, and email sequences.
Installation
npm install @xenterprises/fastify-xemail
Quick Start
await fastify.register(xEmail, {
apiKey: process.env.SENDGRID_API_KEY,
from: { email: 'noreply@example.com', name: 'My App' },
})
Sending Emails
// Simple email
await fastify.xemail.send({
to: 'user@example.com',
subject: 'Welcome!',
html: '<h1>Welcome to our app</h1>',
})
// SendGrid template
await fastify.xemail.sendTemplate({
to: 'user@example.com',
templateId: 'd-xxxxx',
dynamicData: {
firstName: 'John',
resetUrl: 'https://app.example.com/reset?token=...',
},
})
AI Context
package: "@xenterprises/fastify-xemail"
type: fastify-plugin
provider: SendGrid
decorates: fastify.xemail
methods:
send: to + subject + html → void
sendTemplate: to + templateId + dynamicData → void
env-required: [SENDGRID_API_KEY]
env-optional: [EMAIL_FROM]
use-when: Sending transactional emails (welcome, password reset, notifications)
