@meridianjs/email-sendgrid
v1.0.0
Published
SendGrid email provider module for Meridian
Readme
@meridianjs/email-sendgrid
SendGrid email provider for MeridianJS. Registers an emailService in the DI container that implements the IEmailService interface.
Installation
npm install @meridianjs/email-sendgridConfiguration
// meridian.config.ts
export default defineConfig({
modules: [
{
resolve: "@meridianjs/email-sendgrid",
options: {
apiKey: process.env.SENDGRID_API_KEY ?? "",
fromAddress: process.env.EMAIL_FROM ?? "[email protected]",
},
},
],
})Add to your .env:
SENDGRID_API_KEY=SG.your_api_key
[email protected]Usage
import type { IEmailService } from "@meridianjs/types"
const emailSvc = container.resolve("emailService") as IEmailService
await emailSvc.send({
to: "[email protected]",
subject: "Sprint completed",
html: "<p>Sprint 3 has been completed.</p>",
text: "Sprint 3 has been completed.",
})Notes
- Only one email provider should be registered at a time — all three (
email-resend,email-sendgrid,email-ses) register under the sameemailServicetoken. - Both
htmlandtextare optional — pass at least one.
License
MIT
