Skip to content

A lightweight email-sending API built with FastAPI and Python's built-in smtplib. This project provides a simple /send-email endpoint that can be used to send plain text emails using SMTP (Gmail or any SMTP provider). Ideal for small apps, internal tools, or testing notification systems without relying on external services.

Notifications You must be signed in to change notification settings

Etriii/fastapi-smtp-email-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Emailer

This is a simple email sender service built with FastAPI and Python's smtplib for sending emails. It exposes an API endpoint (/api/email/send-email) that allows you to send emails through an SMTP server (e.g., Gmail).

Features

  • Send custom emails with a subject and body
  • Uses SMTP (works with Gmail, or other SMTP providers)
  • Supports plain text emails
  • Configurable with environment variables

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/fastapi-emailer.git
cd fastapi-emailer
  1. Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # On Windows, use 'venv\Scripts\activate'

(Ensure to enable it during dependency updates and utilize it as an interpreter)
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables (.env file):
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=youremail@gmail.com
EMAIL_HOST_PASSWORD=your_app_password

If using Gmail, generate an App Password — don't use your actual password.
  1. Run the FastAPI application:
uvicorn app.main:app --reload
  1. Access the email endpoint at:
POST /api/email/send-email
  1. Example Request using postman
{
  "to": "recipient@example.com",
  "subject": "Test Email",
  "body": "Hello from Alex!"
}

About

A lightweight email-sending API built with FastAPI and Python's built-in smtplib. This project provides a simple /send-email endpoint that can be used to send plain text emails using SMTP (Gmail or any SMTP provider). Ideal for small apps, internal tools, or testing notification systems without relying on external services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages