Email is ideal for rich content delivery, transactional notifications, and messages that need to be referenced later.
When to Use Email
- Transactional emails: Order confirmations, receipts, shipping updates
- Account notifications: Password resets, security alerts, welcome emails
- Rich content: HTML formatting, images, detailed information
- Asynchronous communication: Messages that don’t require immediate attention
Email operates as a separate channel and does not participate in smart routing. You must explicitly specify channel: "email" or send to an email address.
Sending an Email
const result = await zavu.messages.send({
to: "user@example.com",
channel: "email",
subject: "Your order has shipped",
text: "Hi John, your order #12345 has shipped and will arrive in 2-3 business days."
});
HTML Emails
Send rich HTML emails by including htmlBody. The text field serves as the plain-text fallback:
const result = await zavu.messages.send({
to: "user@example.com",
channel: "email",
subject: "Welcome to Zavu",
text: "Welcome to Zavu! We are excited to have you on board.",
htmlBody: `
<h1>Welcome to Zavu!</h1>
<p>We are excited to have you on board.</p>
<a href="https://dashboard.zavu.dev">Get Started</a>
`,
replyTo: "support@yourcompany.com"
});
Request Fields
| Field | Required | Description |
|---|
to | Yes | Valid email address |
channel | Yes | Must be "email" |
subject | Yes | Email subject line (max 998 chars) |
text | Yes | Plain text body |
htmlBody | No | HTML version of the email |
replyTo | No | Reply-To email address |
Channel Detection
If you send to an email address without specifying a channel, Zavu automatically selects email:
const result = await zavu.messages.send({
to: "user@example.com",
subject: "Hello",
text: "This will be sent as email automatically"
});
Setting Up Email
Before sending emails, you need to configure your sender with a verified domain.
1. Add Your Domain
Go to Email Domains in the dashboard and add your domain (e.g., yourcompany.com).
Add the DKIM records provided by Zavu to your DNS:
selector1._domainkey.yourcompany.com CNAME selector1.dkim.zavu.dev
selector2._domainkey.yourcompany.com CNAME selector2.dkim.zavu.dev
selector3._domainkey.yourcompany.com CNAME selector3.dkim.zavu.dev
DNS propagation typically takes a few minutes, but can take up to 48 hours in some cases.
3. Verify Domain
Zavu automatically checks your DNS records every 5 minutes. Once verified, your domain status will change to verified.
4. Assign to Sender
Assign the verified domain to a sender and configure your from address:
- From address:
noreply@yourcompany.com
- Reply-To address:
support@yourcompany.com (optional)
Delivery Status
Check message status by ID:
const result = await zavu.messages.get({ messageId: "msg_abc123" });
console.log("Status:", result.message.status);
| Status | Description |
|---|
queued | Accepted, pending delivery |
sending | Being sent to recipient |
delivered | Confirmed delivered |
failed | Delivery failed |
Common Errors
| Error | Description | Solution |
|---|
subject_required | Missing subject line | Include subject field |
sender_not_configured | Sender lacks email setup | Configure email domain on sender |
domain_not_verified | Domain not verified | Complete DNS verification |
bounce | Email bounced | Invalid or non-existent email address |
complaint | Marked as spam | Review email content and sending practices |
Email vs SMS/WhatsApp
| Feature | Email | SMS / WhatsApp |
|---|
| Smart Routing | No - explicit channel | Yes - auto-selected |
| Automatic Fallback | No | Yes |
| Recipient Type | Email address | Phone number (E.164) |
| Rich Content | Full HTML support | Limited (WhatsApp only) |
| Delivery Speed | Minutes | Seconds |
Email is a separate channel and does not fall back to SMS/WhatsApp if delivery fails.
Best Practices
- Always include plain text - Some email clients only show plain text
- Use a verified domain - Improves deliverability and avoids spam filters
- Set Reply-To - Make it easy for recipients to respond
- Keep subjects clear - Descriptive subjects improve open rates
- Test before sending - Preview HTML emails in multiple clients
- Respect unsubscribes - Honor opt-out requests promptly
Compliance
Email messaging is regulated. Ensure you comply with CAN-SPAM, GDPR, and other applicable laws.
Requirements
- Consent: Have permission before sending marketing emails
- Unsubscribe: Include a working unsubscribe link
- Sender identification: Clearly identify your business
- Physical address: Include your business address (for marketing emails)
- Honest subject lines: Don’t use deceptive subject lines
Example Compliant Email
<h1>Your Order Has Shipped!</h1>
<p>Hi John, your order #12345 has shipped.</p>
<p>Track your package: <a href="https://track.co/abc">View Tracking</a></p>
<hr>
<p style="font-size: 12px; color: #666;">
YourCompany, Inc. | 123 Main St, San Francisco, CA 94102<br>
<a href="https://yourcompany.com/unsubscribe">Unsubscribe</a>
</p>