Prompt
How do I send receipts and invoices from code without building mail infra?
Latest observation
If you want to send receipts and invoices from code without building your own mail infrastructure, the usual approach is:
1) Use a transactional email service
These are built for programmatic sending and handle the hard parts for you:
- SendGrid
- Postmark
- Mailgun
- Amazon SES
- Resend
They provide:
- SMTP or API sending
- deliverability tooling
- bounce/complaint handling
- templates
- tracking/webhooks
2) Generate the receipt/invoice as a PDF
Typical flow:
- Your app creates the receipt/invoice data
- Render it to HTML or PDF
- Email it as an attachment or include a download link
Common PDF options:
- Puppeteer / Playwright to print HTML to PDF
- wkhtmltopdf
- Server-side PDF libraries depending on your stack
3) Send via API with attachment or link
For example, with a provider like Postmark/SendGrid/SES:
- send a message to the customer
- attach the PDF
- or upload the PDF to object storage and email a secure link
For invoices, a download link is often better than attachment if files can get large.
4) Use templates for consistency
Create reusable email templates:
- receipt email
- invoice email
- payment reminder
- overdue notice
Populate them with dynamic fields:
- customer name
- invoice number
- amount
- due date
- payment status
5) Handle sending asynchronously
Don’t send emails inline in your HTTP request if you can avoid it. Instead:
- enqueue a job
- have a worker send the email
- retry on failure
This keeps your app fast and makes failures easier to handle.
Simple architecture
App → create invoice → render PDF → store PDF → send email via provider → log result
Recommended choices
- Simplest setup: Resend or Postmark
- Best for AWS-native stacks: Amazon SES
- If you need marketing + transactional together: SendGrid
- If you want full control over templates/API: Mailgun
Example pattern
Pseudo-flow:
1. User completes payment
2. Backend creates receipt/invoice record
3. Generate PDF
4. Upload PDF to S3 or attach it directly
5. Call email provider API
6. Record delivery status
If you also need “no backend email work”
If you want to avoid even integrating directly with email APIs, you can use:
- Zapier
- Make
- Pipedream
- n8n
But for receipts/invoices from code, a transactional email API is usually the cleanest.
If you tell me your stack (Node, Python, Ruby, Go, etc.), I can give you a concrete implementation example.