@pandodev/email-sdk
v1.0.4
Published
Internal Pando SDK with built-in Email functionality
Readme
Installation
npm install @pandodev/email-sdk
Configuration
Create a .env file in your project and set the following variables:
SENDGRID_API_KEY=your-sendgrid-api-key
[email protected]
[email protected]Usage
Import and Initialize the SDK
import { EmailService } from '@pandodev/email-sdk';
const emailService = new EmailService();Alternatively, you can pass configuration directly:
const emailService = new EmailService({ apiKey: 'your-sendgrid-api-key', defaultTo: '[email protected]', defaultFrom: '[email protected]' });
Sending an Email
There are several parameters to use the sendEmail method:
/**
* @param subject - The subject of the email.
* @param to - The recipient email address (optional, defaults to `this.defaultTo` if not provided).
* @param from - The sender email address (optional, defaults to `this.defaultFrom` if not provided).
* @param html - The raw HTML content of the email (optional).
* @param templateId - The ID of a SendGrid template to use for the email (optional).
* @param dynamicTemplateData - Dynamic data to populate within the SendGrid template (optional).
* @param attachments - An array of attachments to include in the email (optional).
* @returns A promise that resolves when the email is sent.
*/
await emailService.sendEmail('Welcome to Our Service', '[email protected]', '[email protected]','<h1>Hello, welcome!</h1>');