MailAPIX is a robust RESTful backend API built using FastAPI, PostgreSQL, and smtplib to facilitate secure, scalable, and customizable email delivery. It supports user management, secure tokens, and email template-based communication.
MailAPIXAPI/
├── Controller/ # Business logic (email sending, validations)
├── Routers/ # FastAPI route definitions
├── database.py # DB connection and session config
├── main.py # FastAPI app entry point
├── models.py # SQLAlchemy models
├── schema.py # Pydantic schemas
├── utils.py # Token gen, email formatting, helper functions
└── .env # Environment variables
- ✅ User registration with token delivery
- 📧 Email sending with multiple templates (via SMTP)
- 🔒 Token-based security & password protection
- ⚡ Async request handling
- 📚 Clean project structure (Controller, Routers, Models, Utils)
- 📨 System default vs User email-based delivery
- Python 3.8+
- PostgreSQL
- pip
git clone https://github.com/Sumit0ubey/MailAPIX.git
cd MailAPIX
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txtDATABASE_URL=postgresql://user:password@localhost/dbname
DEFAULT_EMAIL=default@yourdomain.com
DEFAULT_PASSKEY=yourpassword
SMTP_SERVER=smtp.yourdomain.com
SMTP_PORT=587
uvicorn main:app --reloadVisit http://127.0.0.1:8000/docs for Swagger UI.
GET /
Returns API metadata: name, description, available routes, IDE used, and duration of development.
All /users endpoints manage registration, upgrades, tokens, and securing the account.
Creates a user.
Body:
{
"full_name": "John Doe",
"email": "john@example.com"
}Behavior: Adds user to DB, sends email with token.
Requires Header: token: <token>
Returns: Full name, email, token, isPaidUser, numberOfEmailsSent, createdAt
Requires Header: token: <token>
Sends an email with available subscription plans.
Requires Header: token: <token>, id, (optional password)
Sends a new token to the user's email after verification.
Requires: id, email, setPassword, confirmPassword, token
Returns: Success message
These routes send emails using different credentials and templates.
Sends email using the user’s email and passKey.
Fields:
Requires Header: token: <token>
{
"title": "Hello",
"content": "Welcome!",
"sendTo": "someone@example.com",
"passKey": "user_email_password",
}
query_parameter = template_id=1&company_name=YourCo&company_link=https:/yourco.com&email_title=Notification (optional)Same fields, except no passKey. Uses API’s default email configured.
| ID | Name | Description |
|---|---|---|
| 0 | Simple | No formatting, plain text |
| 1 | Cool | Header, body, footer layout |
| 2 | Amazing | Stylized layout with modern UI |
| 3 | Custom | Full customization + brand fields like logo, footer, etc. |
Supported Optional Fields:
company_namecompany_linkemail_title
These enhance professional look and personalization in templates 1, 2, and 3.
| File/Folder | Purpose |
|---|---|
main.py |
App entry point, includes routers |
database.py |
DB session creation |
models.py |
SQLAlchemy models (User, etc.) |
schema.py |
Pydantic models for validation |
utils.py |
Token creation, email formatting utilities |
Routers/ |
API route logic for /users, /email |
Controller/ |
Functional logic (sending emails, verifying users, formatting) |
You can use tools like:
- Swagger UI (
/docs) - Postman collection (optional)
- Curl scripts
Made with ❤️ by Sumit Dubey
This project is open-source for educational and reference purposes. It is hosted at: 🔗 MailAPIX
You may view, learn from, and fork this repository, but you are not permitted to republish, resell, or claim it as your own under any circumstances.
All original work © 2025 Sumit Dubey. All rights reserved.
For collaboration or licensing inquiries, please contact the author directly through GitHub.