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.
- 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
- macOS
- Homebrew
- Python 3.7+
- pip
- Nginx
- RabbitMQ
- Ngrok
- Install the required system dependencies using Homebrew:
brew install python nginx rabbitmq- Install Ngrok following the official documentation:
brew install ngrok/ngrok/ngrok
ngrok config add-authtoken <token>- Clone this repository:
git clone https://github.com/Rob-in-son/HNG-stage3.git
cd HNG-stage3- Create a virtual environment and activate it
python3 -m venv messaging_env
source messaging_env/bin/activate- Install the required Python packages:
pip install Flask celery pika smtplib- Copy the sample.config.py file to config.py and update it with your SMTP and Celery settings:
cp sample.config.py config.pyThe 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 should work with its default configuration. If you need to make changes, refer to the RabbitMQ documentation. Usage
- Start RabbitMQ:
brew services start rabbitmq- Start Celery worker:
celery -A app.celery worker --loglevel=info- Start the Flask application:
python app.py- Start Nginx:
brew services start nginx- Start Ngrok to expose your local server:
ngrok http http://localhost:80http://<ngrok-url>/?sendmail=email@example.com: Sends an email to the specified addresshttp://<ngrok-url>/?talktome: Logs the current timehttp://<ngrok-url>//logs: Displays the application logs
- 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.