Skip to content
/ bulker Public

Go-based service for sending emails using an HTTP endpoint and RabbitMQ for message queuing.

License

Notifications You must be signed in to change notification settings

qnton/bulker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bulker

This project consists of a Go-based service for sending emails using an HTTP endpoint and RabbitMQ for message queuing. The service reads from a RabbitMQ queue and sends emails using the specified SMTP server. The service ensures reliable message processing, including retry mechanisms and persistence in the event of crashes.

Features

  • HTTP API to receive email data and queue it for processing.
  • Uses RabbitMQ for message queuing to handle email sending asynchronously.
  • SMTP integration to send emails.
  • Retry logic for failed email deliveries.
  • Error logging for troubleshooting.

Prerequisites

  • Go installed on your device or use Docker.
  • A running RabbitMQ instance.
  • An SMTP server for sending emails.

Installation

  1. Clone the Repository:
git clone https://github.com/qnton/bulker
cd email-service
  1. Set Up Environment Variables:

Create a .env file in the root directory of the project and set the following environment variables:

RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASS=guest
SMTP_SERVER=email-smtp.eu-central-1.amazonaws.com
SMTP_PORT=465
SMTP_USER=user
SMTP_PASS=pass
SMTP_FROM=test@example.com
AUTH_KEY=qwerty
  1. Example Docker Compose Setup

Create a docker-compose.yml file with the following content:

services:
  rabbitmq:
    image: rabbitmq:latest
    ports:
      - "5672:5672"
    environment:
      RABBITMQ_DEFAULT_USER: guest
      RABBITMQ_DEFAULT_PASS: guest

  app:
    build: .
    ports:
      - "8080:8080"
    depends_on:
      - rabbitmq
    env_file:
      - .env
    restart: always
  1. Build and Run the Services:

Ensure Docker and Docker Compose are installed, then use the following command to build and start the services:

docker-compose up --build

Usage

HTTP API Endpoint

The service exposes an HTTP POST endpoint at http://localhost:8080/send-mail to receive email data and queue it for processing.

Example Request

curl -X POST \
  http://localhost:8080/send-mail \
  -H 'Content-Type: application/json' \
  -H 'Authorization: qwerty' \
  -d '{
	"recipient_list": [
		{"name": "Max", "to": "email1@example.com"},
		{"name": "Mustermann", "to": "email2@example.com"}
	],
	"subject": "Hello {{.name}}",
	"content": "<p>Hello <b>{{.name}}</b></p>"
}'

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Go-based service for sending emails using an HTTP endpoint and RabbitMQ for message queuing.

Topics

Resources

License

Stars

Watchers

Forks