Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Python Email Messaging System

This is a Flask-based email messaging system that uses RabbitMQ and Celery for asynchronous task processing. It's designed to run on macOS and uses Nginx as a reverse proxy, with Ngrok for exposing the local server to the internet.

Features

  • Send emails asynchronously
  • Real-time status updates using Server-Sent Events (SSE)
  • Logging system for tracking email sending status
  • Web interface for viewing logs
  • Scalable architecture using Celery and RabbitMQ

Prerequisites

  • macOS
  • Homebrew
  • Python 3.7+
  • pip
  • Nginx
  • RabbitMQ
  • Ngrok

Installation

  1. Install the required system dependencies using Homebrew:
brew install python nginx rabbitmq
  1. Install Ngrok following the official documentation:
brew install ngrok/ngrok/ngrok
ngrok config add-authtoken <token>
  1. Clone this repository:
git clone https://github.com/Rob-in-son/HNG-stage3.git
cd HNG-stage3
  1. Create a virtual environment and activate it
python3 -m venv messaging_env
source messaging_env/bin/activate
  1. Install the required Python packages:
pip install Flask celery pika smtplib
  1. Copy the sample.config.py file to config.py and update it with your SMTP and Celery settings:
cp sample.config.py config.py

Edit config.py with your actual SMTP and Celery settings.

Nginx Configuration

The Nginx configuration file is located at /opt/homebrew/etc/nginx/nginx.conf. Add the following server block to this file:

server {
    listen 80;
    server_name localhost;
    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

RabbitMQ Configuration

RabbitMQ should work with its default configuration. If you need to make changes, refer to the RabbitMQ documentation. Usage

  1. Start RabbitMQ:
brew services start rabbitmq
  1. Start Celery worker:
celery -A app.celery worker --loglevel=info
  1. Start the Flask application:
python app.py
  1. Start Nginx:
brew services start nginx
  1. Start Ngrok to expose your local server:
ngrok http http://localhost:80

API Endpoints

  • http://<ngrok-url>/?sendmail=email@example.com: Sends an email to the specified address
  • http://<ngrok-url>/?talktome: Logs the current time
  • http://<ngrok-url>//logs: Displays the application logs

Troubleshooting

  • If you encounter permission issues with Nginx, make sure you're running it with sudo privileges.
  • If emails are not being sent, check your SMTP settings in the config.py file.
  • If Celery tasks are not being processed, ensure that RabbitMQ is running and the Celery worker is started.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages