mail-server

command module
v0.0.0-...-bc7fc27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

README

Mail Server Setup (Systemd)

# Install the app
go install github.com/p-tupe/code-examples/go/mail-server

# Pull .env.sample
curl -fsSL -o .env \
    https://raw.githubusercontent.com/p-tupe/code-examples/refs/heads/main/go/mail-server/.env.sample

# Modify the variables
$EDITOR .env

# Pull the service file
curl -fsSL -o go-mail-server.service \
    https://raw.githubusercontent.com/p-tupe/code-examples/refs/heads/main/go/mail-server/go-mail-server.service


# Modify the exec path and environ file var
$EDITOR go-mail-server.service

# Copy service file to systemd dir
sudo cp mail-server.service /etc/systemd/system/

# Enable on login and start immediately
sudo systemctl daemon-reload
sudo systemctl enable --now go-mail-server

# Check logs to ensure it is running
sudo journalctl -u go-mail-server

To send a simple email:

curl -H "Authorization: some-auth-string" -d "email body" localhost:8080

To send a custom email:

curl -H "Authorization: some-auth-string" --json '{"to":["x@mail.com"],"subject":"Hello","message":"Hello again!"}' localhost:8080/custom

Documentation

Overview

This is a simple mail server implementation that accepts an email body content on POST / in form of a custom (To,Subject,Message) json body or simple plain text, and sends it over via SMTP using go's builtin net/smtp(https://pkg.go.dev/net/smtp) package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL