Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.

1. Install Dependencies

npm

2. Create Email Module

Create src/email/email.module.ts:
TypeScript

3. Create Email Service

Create src/email/email.service.ts:
TypeScript

4. Configure Environment Variables

Create .env:
Update app.module.ts:
TypeScript

5. Create Email Controller

Create src/email/email.controller.ts:
TypeScript

6. Common Use Cases

Welcome Email Service Method

Add to email.service.ts:
TypeScript

Password Reset Email

TypeScript

7. Using in Other Services

TypeScript

8. Using with Queues (Bull)

Install Bull:
Create email queue:
TypeScript
Create processor:
TypeScript
Make sure your sender email domain is verified in your SendPost account before sending emails.

9. Next Steps

Explore more examples and use cases:

NestJS Documentation

Learn more about NestJS framework

SendPost JavaScript SDK

View the official SDK package on npm

Quickstart Example

View a complete working example on GitHub