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.txtTo start the FastAPI server locally:
python main.pyOnce 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": "toemail@gmail.com"
})
print(response.json())import requests
response = requests.post('http://0.0.0.0:8000/sendEmail', json={
"fromEmail": "fromemail@gmail.com",
"passkey": "your-16-digit-app-password",
"toEmail": "toemail@gmail.com",
"title": "Your Title",
"subject": "Your Subject",
"body": "Your body message"
})
print(response.json())💡 If
fromEmailandpasskeyare 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": "defaultemailapi@gmail.com",
"passkey": "your-16-digit-app-password"
}{
"fromEmail": "fromemail@gmail.com",
"passkey": "16-digit-app-password",
"toEmail": "toemail@gmail.com",
"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.