Kaupskip (Old Norse for "merchant ship") is a modern, event-driven email service designed to manage all transactional and marketing emails for your application. Just as merchant ships were the reliable carriers of goods in Norse times, Kaupskip reliably delivers your important communications to users.
This microservice is built with FastAPI and implements a clean, event-driven architecture that seamlessly integrates with your main application through Redis pub/sub channels.
- 🚀 Event-Driven Architecture: Listens for events from your main application and sends appropriate emails
- 📧 Templated Emails: Beautiful, responsive HTML email templates with the Catppuccin Macchiato color scheme
- 🔐 Verification Flows: Built-in support for email verification workflows
- 📊 Email Logging: Comprehensive logging of all email activities
- 🔄 Subscription Management: Templates for subscription events (receipts, cancellations, etc.)
- 🧪 Testing Tools: Utilities for testing email templates
- Docker and Docker Compose
- Redis server (can be run in Docker)
- SMTP server credentials (for sending emails)
- Copy the example environment file and fill in your settings:
cp .env.example .env
- Update the following variables in your
.env
file:
SMTP_HOST=your-smtp-server.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your-password
SERVICE_NAME=Your Service Name
MAIN_APP_URL=http://localhost:8000
SITE_URL=https://your-site.com
The simplest way to get started is using Docker Compose:
docker-compose up -d
This will:
- Build the Kaupskip container
- Connect to your Redis instance
- Expose the service on port 8001
- Set up health checks
If you prefer to run without Docker:
- Install dependencies:
pip install -r requirements.txt
- Run the service:
cd email_service
uvicorn src.main:app --host 0.0.0.0 --port 8001
GET /health
: Health check endpointPOST /verify/email
: Request email verificationGET /verify/status/{user_id}
: Check verification statusGET /logs/email
: List email logs
Kaupskip listens to the following Redis channels:
user_registration
: For new user signupskaupskip:subscription
: For subscription eventskaupskip:marketing
: For marketing events
# Publishing a user registration event
import json
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
event_data = {
"user_id": "user123",
"email": "[email protected]",
"verification_token": "abc123",
"verification_url": "https://example.com/verify?token=abc123"
}
r.publish('user_registration', json.dumps(event_data))
Kaupskip includes the following pre-designed email templates:
- Verification emails
- Welcome emails
- Subscription receipts
- Subscription cancellation notices
- Account change notifications
- Trial expiration reminders
All templates use the modern Catppuccin Macchiato color scheme and are designed to be responsive across devices.
To test email templates without sending actual emails, use the provided preview files or the test endpoint:
python -m src.utils.send-email-test
Then make a POST request to http://localhost:8002/test-email
with:
{
"to_email": "[email protected]",
"template_name": "welcome"
}
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.