Skip to main content

Basic Usage

Configuration

Email Providers

Zero-configuration email sending via Cloudflare Email Routing:
wrangler.toml configuration:
Features:
  • No API key required
  • Automatic DKIM signing
  • 100,000 emails/day free tier
  • Edge-native performance
  • Instant delivery

Resend

Developer-friendly email API with great deliverability:
Environment Variables:
Features:
  • Simple REST API
  • Email analytics dashboard
  • 100 emails/day free tier
  • Webhook support
  • React Email integration

SMTP

Generic SMTP for any mail server:
Supported Services:
  • Gmail
  • SendGrid
  • Mailgun
  • Amazon SES
  • Custom SMTP servers

Email Templates

Inline HTML

Simple emails with inline HTML:

Template Variables

Use template expressions for dynamic content:

Liquid Templates (Advanced)

For complex templates, store them in KV with Liquid syntax:
Template in KV:

Email Attachments

Single Attachment

Multiple Attachments

Attachment from Storage

Batch Sending

Send personalized emails to multiple recipients:
Output:

CC and BCC

Reply-To

Set a different reply address:

Custom Headers

Add tracking and custom headers:

Tags and Metadata

Organize and track emails:

Common Patterns

Transactional Email

Welcome Email Workflow

Password Reset Email

Email with PDF Invoice

Data Export Email

Newsletter Campaign

Error Handling

Retry on Failure

Fallback Provider

Validate Email Address

Testing

Test with TestConductor

Mock Email Provider

Best Practices

1. Use Plain Text Fallback
2. Validate Recipients
4. Rate Limit Batch Sending
5. Include Unsubscribe Link
6. Use Tags for Organization
7. Store API Keys in Environment
8. Handle Attachments Safely

Pitfall: HTML Without Plain Text

Pitfall: No Error Handling

Pitfall: Batch Without Rate Limiting

Next Steps

sms Operation

Send SMS messages

pdf Operation

Generate PDF documents

storage Operation

Store email templates

Testing

Test email workflows