Skip to content

trouchet/fastapi-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Email Application

A FastAPI application for sending professional emails with dynamic content using SMTP and HTML templates.

Features

  • Send emails using Gmail SMTP.
  • Render HTML email templates with Jinja2.
  • Send emails asynchronously in the background.

Setup

  • Clone the Repository
git clone https://github.com/yourusername/fastapi-email.git
cd fastapi-email

Create and Activate a Virtual Environment

python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate for Windows

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Create a .env file with your Gmail SMTP credentials:

    SMTP_SERVER=smtp.gmail.com
    SMTP_PORT=465
    SMTP_USERNAME=your-email@gmail.com
    SMTP_PASSWORD=your-email-password
    SENDER_EMAIL=your-email@gmail.com

Templates

  • HTML Template: Located in templates/html_template.html

Running the Application

Start the FastAPI Server

uvicorn main:app --reload

Send a Test Email

Use the send_email_background function in main.py or integrate it into an endpoint.

About

A FastAPI app to send e-mails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published