Skip to content

A Go-based email service with support for multiple providers like Mailgun and SparkPost. Exposes a RESTful API for sending emails via HTTP POST requests. Includes Docker support for deployment and environment-based configuration for flexibility. Ideal for integrating reliable email-sending functionality into applications.

Notifications You must be signed in to change notification settings

MartinLupa/go-email-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Email Service

Overview

This is a simple email service built with Go, designed to send emails using different providers such as Mailgun and SparkPost. It exposes a RESTful API that allows clients to send emails by making HTTP POST requests.

Features

  • Supports multiple email providers (Mailgun, SparkPost).
  • Simple RESTful API for sending emails.
  • Environment-based configuration using .env file.
  • Docker support for easy deployment.

Getting Started

Prerequisites

  • Go installed on your machine.
  • Docker installed (for Docker-based deployment).
  • Environment variables set in a .env file.

Installation

  1. Clone the repository:

    git clone https://github.com/MartinLupa/go-email-service.git
    cd go-email-service
  2. Set up environment variables:

    Create a .env file in the root of the project with the following content:

    PORT=8080
    MAILGUN_API_KEY=your-mailgun-api-key
    MAILGUN_DOMAIN=your-mailgun-domain
    SPARKPOST_API_KEY=your-sparkpost-api-key
  3. Build and run the service:

    You can either run the service directly using Go or use Docker.

    • Using Go:

      go run main.go
    • Using Docker Compose:

      Build the Docker image:

      docker-compose up

Usage

API Endpoint

  • POST /send-email

Request Payload

To send an email, make a POST request to http://localhost:8080/send-email with the following JSON payload:

{
    "subject": "Some important email",
    "body": "Some important information in some important email",
    "to": "[email protected]"
}

About

A Go-based email service with support for multiple providers like Mailgun and SparkPost. Exposes a RESTful API for sending emails via HTTP POST requests. Includes Docker support for deployment and environment-based configuration for flexibility. Ideal for integrating reliable email-sending functionality into applications.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published