Examples

Real delivery patterns, kept lightweight.

This page is now a quick overview of common worker-mailer use cases. The code stays in the documentation so the rest of the site can breathe a little more.

smtp-basic.ts

Direct SMTP delivery

Connect once and send from a Worker when the request itself owns the delivery flow.

send-once.ts

One-off send

Use the static helper when you do not need to retain a transport instance between sends.

queue.ts

Queue consumer

Push email work into Cloudflare Queues to keep the request path thin.

inline-image.ts

HTML + CID image

Embed an inline image in the message body using a content ID attachment.

hooks.ts

Lifecycle hooks

Monitor connect, sent, error, and close events with typed hooks.