- List all emails: Retrieve all sent or scheduled emails, with the option to filter by status (e.g., sent, pending, failed).
- Get specific email details: Fetch detailed information of a specific email using its unique identifier (UUID).
- Immediate email sending: Enable sending an email instantly through the dedicated endpoint.
- Schedule email sending: Support scheduling emails to be sent at future times, facilitating campaigns or timed notifications.
- Cancel scheduled emails: Allow cancellation of previously scheduled emails by referencing the schedule’s UUID.
git clone https://github.com/TechAbraao/email-sender-rest-api.git
- Create and activate the virtual environment
python3 -m venv .venv
# Activate the virtual environment (Linux or Mac)
source .venv/bin/activate
# Or, if you're on Windows
# .venv\Scripts\activate
- Install dependencies
pip install -r src/requirements.txt
- At the root of the project, run:
# Creates virtual environment (.venv) and Installs dependencies from src/requirements.txt
make start-setup
Configure these main variables:
# E-mail Configuration
SMTP_SERVER= # Example: smtp.gmail.com
SMTP_PORT=
SMTP_EMAIL=
SMTP_PASSWORD=
# Database PostgreSQL and PGAdmin4 Configurations
## PostgreSQL Configurations
DATABASE_HOST=
DATABASE_PORT=
DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_NAME=
If necessary, configure the rest (they are at default values):
# Default App Flask Configurations
FLASK_APP=src.app.flask_app:create_app
FLASK_ENV=development
FLASK_DEBUG=1
PYTHONPATH=.
## PGAdmin4 Configurations
[email protected] # This is the default E-MAIL. Change it if necessary.
PGADMIN_PASSWORD=admin # This is the default PASSWORD. Change it if necessary.
PGADMIN_HOST=5050 # This is the default HOST. Change it if necessary.
PGADMIN_PORT=80 # This is the default PORT. Change it if necessary.
# RabbitMQ Configuration
RABBITMQ_DEFAULT_HOST=localhost # This is the default HOST. Change it if necessary.
RABBITMQ_DEFAULT_PORT=5672 # This is the default PORT. Change it if
RABBITMQ_DEFAULT_NAME=celery # This is the default NAME. Change it if necessary.
RABBITMQ_DEFAULT_USER=root # This is the default USER. Change it if necessary.
RABBITMQ_DEFAULT_PASS=root # This is the default PASSWORD. Change it if necessary.
This messaging architecture uses Flask as the application framework, RabbitMQ as the message broker, and Celery as the worker queue for processing asynchronous tasks like sending emails and schedules.
graph LR
Producer["Producer:<br><b>Flask Application</b>"] -->|Message| Exchange["Exchange:<br><b>RabbitMQ</b>"]
Exchange -->|Route the message| Queue["Queue:<br><b>RabbitMQ</b>"]
Queue -->|Message| Worker["Worker:<br><b>Celery Application</b>"]
Method | URL | Description |
---|---|---|
GET | /api/emails |
Get all emails |
GET | /api/emails?status=<status> |
Get all emails with status |
GET | /api/emails/<string:uuid_email> |
Retrieve specific email |
POST | /api/emails/send |
Send email |
POST | /api/emails/schedule |
Schedule email sending |
DELETE | /api/emails/schedule/<string:uuid_task> |
Cancel scheduled email sending |