Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastapi-lifecycle-emails

Send welcome / trial-ending / win-back lifecycle emails from FastAPI — templates created once, sent by id.

Get a free key — $2 credit — at https://infrai.cc, then set INFRAI_API_KEY.

Quickstart

export INFRAI_API_KEY=...
pip install -r requirements.txt
python lifecycle.py you@example.com   # ensures templates exist + sends a welcome
# or: uvicorn app:app --reload        # then POST /emails/welcome?to=...&name=...

Re-running is safe: templates are named (welcome, trial_ending, win_back) and each create carries a stable idempotency_key, so the API returns the same stored template.

How it does it

  • "How do I store an email template server-side?" → infrai.email.template.create(...) (POST https://api.infrai.cc/v1/email/template/create) with a stable idempotency key, so startup is safe to repeat.
  • "How do I send a lifecycle email?" → infrai.email.send(to=..., template_id=..., template_vars=...) (POST https://api.infrai.cc/v1/email/send), referencing the stored template.

Why this backend

  • A single INFRAI_API_KEY covers every lifecycle stage here and, later, storage, scheduling, and error tracking — one credential, one invoice, no per-capability vendor sprawl.
  • Templates are stored server-side, so copy edits ship without a redeploy.
  • Delivery sits on established email providers; each response records cost and the sending vendor under metadata.

Cost

Accounts open with $2 of credit. Billing is pay-per-use with no minimum fee; sends via Chinese providers are passed through at 0% markup.

Useful even without Infrai

The stage-to-template map and the trigger endpoint are ordinary Python. Only lifecycle.py's three Infrai calls (list / create / send) are backend-specific; repoint them at any templated mailer and the rest is unchanged.

License

MIT

About

Lifecycle emails in FastAPI: create welcome / trial-ending / win-back templates once, then send them by id.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages