← Back to all products
$19
Receipt Emailer
Automated receipt email system with customizable templates and delivery confirmation.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 9 files
receipt-emailer/
├── LICENSE
├── README.md
├── examples/
│ └── receipt_data.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_cli-reference.md
│ └── 03_license.md
├── index.html
└── src/
└── receipt_emailer.py
📖 Documentation Preview README excerpt
Receipt Emailer
Part of the Payment Stack by CodeVault
Generate branded HTML payment receipts with itemized charges, download links, and refund notices. Simulates SMTP email delivery for testing.
Features
- Professional, email-client-compatible HTML receipts
- Inline CSS with table-based layout (works in Gmail, Outlook, etc.)
- Itemized charges with quantity, price, and tax per item
- Download links for digital products
- Payment method display (masked card, PayPal, crypto)
- Discount and tax breakdown
- Refund receipt variant with red header
- Simulated SMTP delivery (writes .eml files for inspection)
- MIME multipart with HTML + plain text fallback
- Python stdlib only — zero dependencies
Quick Start
# Generate a demo receipt
python src/receipt_emailer.py --action demo --output receipt.html
# Generate from config
python src/receipt_emailer.py --config examples/receipt_data.json --output receipt.html
# Simulate sending an email
python src/receipt_emailer.py --action send --config examples/receipt_data.json
# Output receipt data as JSON
python src/receipt_emailer.py --action demo --format json
CLI Reference
| Flag | Description |
|---|---|
--action, -a | Action: generate (default), send, demo |
--config, -c | Receipt data JSON file |
--output, -o | Output HTML file (default: stdout) |
--smtp-log | Directory for simulated email files (default: ./smtp_log) |
--format, -f | Output format: html (default) or json |
--verbose, -v | Enable debug logging |
Configuration Reference
See examples/receipt_data.json for a complete example.
| Field | Type | Description |
|---|---|---|
customer_name | string | Customer display name |
customer_email | string | Delivery email address |
items | array | Line items with description, quantity, unit_price, tax, download_url |
currency | string | ISO 4217 code (USD, EUR, GBP) |
payment_method | object | Type (card/paypal/crypto), last_four, brand |
company_name | string | Your company name |
brand_color | string | Hex color for receipt branding |
refund_policy | string | Refund policy text |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/receipt_emailer.py
#!/usr/bin/env python3
"""
Receipt Emailer — Payment Stack by DataNest
Generate branded HTML payment receipts with download links and refund notices.
Produces self-contained HTML receipts that can be sent via email or saved to disk.
Simulates SMTP delivery locally for testing.
Why this exists:
Every payment needs a receipt. Good receipts include itemized charges, tax
breakdowns, payment method hints, download links for digital products, and
clear refund policy text. This tool generates all of that from a JSON config
and can simulate the email delivery flow for testing.
Usage:
python receipt_emailer.py --config receipt_data.json --output receipt.html
python receipt_emailer.py --action send --config receipt_data.json --smtp-log ./smtp_log
python receipt_emailer.py --action demo
License: MIT
"""
from __future__ import annotations
import argparse
import json
import logging
import sys
import uuid
import html as html_mod
from dataclasses import dataclass, field, asdict
from datetime import datetime, timezone
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from pathlib import Path
from typing import Any, Optional
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
DEFAULT_BRAND_COLOR = "#76FF03"
DEFAULT_COMPANY = "Acme Corp"
DEFAULT_SUPPORT_EMAIL = "support@acme-corp.example.com"
DEFAULT_REFUND_POLICY = ("Refunds are available within 30 days of purchase. "
"Contact support for assistance.")
LOG = logging.getLogger("receipt-emailer")
# ---------------------------------------------------------------------------
# ... 407 more lines ...