Skip to content

mrwormhole/emailer

Repository files navigation

Emailer

Version CI Build GoDoc Report Card License Coverage Status

Purpose

Packaging SMTP(send only) APIs to a choosable option is the goal here, then to have a tiny server that picks 1 provider and serves as HTTP endpoint so the other microservices that belong to you can make email requests.

Supported providers

  • Brevo (highly recommended)
  • Resend
  • Postmark
  • Mailchimp
  • Mailtrap
  • Mailjet
  • Mailgun
  • Sendgrid (avoid them if you can)

Note: Anything that only uses oauth2 like zoho does will not be implemented here for foreseeable future

Getting Started

  export API_KEY=<SECRET_API_KEY>
  export PROVIDER=brevo
  go run ./cmd/emailer/main.go -debug

Kick the server by after having PROVIDER and API_KEY env variables then run go run ./cmd/emailer/main.go

Send Emails

This endpoint allows you to send an email by providing the necessary email details in the request body as JSON.

  curl -X POST http://localhost:5555/email \
  -H "Content-Type: application/json" \
  -d '{
    "from": "[email protected]",
    "to": ["[email protected]"],
    "subject": "Test Email",
    "htmlContent": "<p>This is a test email in HTML format.</p>",
    "textContent": "This is a test email in plain text format."
  }'