Sending Emails Guide

Complete guide to sending emails with Metigan. Learn best practices, advanced techniques, and common patterns for sending transactional and marketing emails.

Basic Email Sending

Start with the basics. See the Quick Start guide for your first email.

basic-send.tsTypeScript
1
2
3
4
5
6
7
8
9
10
11
12
import Metigan from 'metigan';

const metigan = new Metigan({
  apiKey: process.env.METIGAN_API_KEY!
});

const result = await metigan.email.sendEmail({
  from: 'sender@example.com',
  recipients: ['recipient@example.com'],
  subject: 'Hello!',
  content: '<p>This is a simple email.</p>'
});

Best Practices

Use Templates

Create reusable templates for consistent branding and easier maintenance. Templates support variables and make it easy to update designs without changing code.

Handle Errors Gracefully

Always check for success and handle errors appropriately. Use type guards for type safety and implement retry logic for transient errors.

Monitor Rate Limits

Monitor rate limit headers and implement queuing for high-volume sends. Respect rate limits to ensure reliable delivery.

Next Steps

Check out the Email API referencefor complete documentation of all available options and parameters.