A lightweight, production-ready email-sending API built with FastAPI. This API enables you to easily send emails using simple HTTP requests. It’s designed for seamless integration in Python, Dart, or any application that supports HTTP.
- Built with FastAPI – fast, modern, and lightweight.
- Easy to use and integrate into any project.
- Supports default email credentials or custom sender configurations.
- Supports email subject, title, and body customization.
- Compatible with both Python and Dart clients.
Clone the repository and install required dependencies:
git clone https://github.com/yourusername/pythonemailapi.git
cd pythonemailapi
pip install -r requirements.txt
To start the FastAPI server locally:
python main.py
Once running, the API will be available at: http://0.0.0.0:8000
import requests
response = requests.get('http://0.0.0.0:8000')
print(response.json())
import requests
response = requests.post('http://0.0.0.0:8000/sendEmail', json={
"toEmail": "[email protected]"
})
print(response.json())
import requests
response = requests.post('http://0.0.0.0:8000/sendEmail', json={
"fromEmail": "[email protected]",
"passkey": "your-16-digit-app-password",
"toEmail": "[email protected]",
"title": "Your Title",
"subject": "Your Subject",
"body": "Your body message"
})
print(response.json())
💡 If
fromEmail
andpasskey
are not provided, the API will use default credentials.
If you're using Gmail, enable 2-Step Verification and generate an app-specific password to use as the passkey
.
Used if fromEmail
and passkey
are omitted from the request:
{
"fromEmail": "[email protected]",
"passkey": "your-16-digit-app-password"
}
{
"fromEmail": "[email protected]",
"passkey": "16-digit-app-password",
"toEmail": "[email protected]",
"title": "Email Title",
"subject": "Email Subject",
"body": "Email Body Content"
}
Shaik Afrid
GitHub: @afriddev
This project is licensed under the MIT License – feel free to use and contribute.