Originally published at claudeguide.io/claude-api-email-generation-templates
Claude API Email Generation Templates
To generate personalized emails with the Claude API, pass your recipient data as variables into a structured system prompt that defines tone, intent, and constraints, then render each message in the user turn. Claude returns ready-to-send copy — no post-processing required. For cold outreach, use claude-haiku-4-5 at $0.0002 per email; for high-value sequences where tone precision matters, switch to claude-sonnet-4-6 at $0.0030. A single Batch API job can generate 1,000 personalized emails overnight at half the synchronous cost.
Prompt Patterns for Cold, Warm, and Transactional Emails
Cold Email
Cold email prompts need a firm word-count ceiling, a clear value hook, and an explicit instruction to avoid spam triggers (more on that in Deliverability Considerations).
import anthropic
client = anthropic.Anthropic()
COLD_EMAIL_SYSTEM = """You are an expert B2B copywriter.
Write a cold outreach email following these rules exactly:
- Subject line: max 50 characters, no all-caps, no exclamation marks
- Body: 80-120 words, plain conversational tone
- One specific pain point tied to the recipient's industry
- One concrete offer or question as the call to action
- No generic openers ("I hope this finds you well", "My name is...")
- No spam trigger words: free, guaranteed, act now, limited time, winner
Return format:
Subject: [subject line]
[email body]"""
def generate_cold_email(recipient: dict) -
The cookbook includes complete email agent blueprints: multi-step outreach sequences, reply-detection loops, CRM sync patterns, and Haiku/Sonnet routing logic for cost-optimized campaign generation. All recipes ship with prompt caching enabled and Batch API integration out of the box.
[→ Get the Agent SDK Cookbook — $49](https://shoutfirst.gumroad.com/l/ogxhmy?utm_source=claudeguide&utm_medium=article&utm_campaign=claude-api-email-generation-templates)
*Instant download. 30-day money-back guarantee.*
---
## Deliverability Considerations: Avoiding Spammy Patterns
AI-generated email fails deliverability for two distinct reasons: **content triggers** (spam-filter keywords) and **structural red flags** (identical copy sent to many recipients). Address both in the prompt and in your sending infrastructure.
**Prompt-level controls:**
python
DELIVERABILITY_RULES = """
Banned words and phrases (never use):
- free, guaranteed, no risk, act now, limited time offer, click here
- winner, congratulations, you have been selected
- $$, 100%, earn money, make money fast
- Excessive punctuation: !!!, ???
Structural rules:
- Vary sentence length — avoid uniform 15-word sentences throughout
- No ALL CAPS words except established acronyms (API, SaaS, CRM)
- Include one genuine question to invite a reply
- Sign off with a real name and role, not a generic "The Team" """
**Infrastructure controls (outside Claude):**
- Send from a warmed domain (at least 30 days old with gradual volume ramp)
- Limit daily send volume to under 200 per domain until reputation is established
- Use a unique `custom_id` per recipient and deduplicate before sending
- Add plain-text MIME part alongside HTML — spam filters penalize HTML-only emails
- Honor unsubscribe immediately; bounce rate above 2% triggers ISP throttling
Even with perfect copy, high send volume from a cold domain will land in spam. The Claude prompt controls content quality; your ESP configuration controls inbox placement.
---
## Template Versioning Pattern
As your prompts evolve, version them explicitly. This lets you A/B test prompt versions across campaigns and roll back if quality drops.
python
from dataclasses import dataclass
from datetime import date
@dataclass
class EmailTemplate:
version: str
model: str
system: str
max_tokens: int
created: str
TEMPLATES: dict[str, EmailTemplate] = {
"cold_v1": EmailTemplate(
version="cold_v1",
model="claude-haiku-4-5",
system=COLD_EMAIL_SYSTEM,
max_tokens=400,
created="2026-04-01",
),
"cold_v2": EmailTemplate(
version="cold_v2",
model="claude-haiku-4-5",
system=COLD_EMAIL_SYSTEM + "\n- Open with a specific industry stat if possible.",
max_tokens=450,
created="2026-04-30",
),
}
def generate_with_template(template_key: str, recipient: dict) -
Go beyond single-email generation: the cookbook's email chapter covers a full agentic pipeline — CRM data ingestion, multi-step sequence generation, reply detection, and automated follow-up scheduling. Built on the Anthropic Agent SDK with Batch API integration, prompt caching, and template versioning baked in.
→ Get the Agent SDK Cookbook — $49
Instant download. 30-day money-back guarantee.
Sources
- Anthropic — Claude model pricing — April 2026
- Anthropic — Message Batches API — April 2026
- Anthropic — Rate limits — April 2026
Top comments (0)