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.
- Supports multiple email providers (Mailgun, SparkPost).
- Simple RESTful API for sending emails.
- Environment-based configuration using
.env
file. - Docker support for easy deployment.
- Go installed on your machine.
- Docker installed (for Docker-based deployment).
- Environment variables set in a
.env
file.
-
Clone the repository:
git clone https://github.com/MartinLupa/go-email-service.git cd go-email-service
-
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
-
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
-
- POST
/send-email
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]"
}