A simple email server that allows you to create inboxes and rules to filter emails, written in Go.
- HTTP API for managing projects, inboxes, and rules
- SMTP server for receiving emails
- IMAP server for accessing emails
- Rule-based email filtering
- Configurable via YAML and environment variables
- Install dependencies:
make deps
- Start the development servers:
make dev # Starts PostgreSQL and Go server
make run-frontend # In another terminal, starts Vite dev server
Visit http://localhost:8080 for the API and http://localhost:5173 for the development frontend.
The application can be configured via:
- Environment variables (highest precedence)
- Configuration file
- Default values
Example configuration:
server:
http:
port: ":8080"
smtp:
domain: "smtp.example.com"
hostname: "localhost"
allow_insecure_auth: true
msa:
port: "587"
tls: false
mta:
port: "1025"
tls: false
imap:
port: ":1143"
hostname: "localhost"
tls: false
allow_insecure_auth: true
# Shared TLS certificate configuration for all services
tls:
cert_file: "/path/to/cert.pem"
key_file: "/path/to/key.pem"
email_domain: "example.com"
database:
url: "postgres://inbox:inbox@localhost:5432/inbox451?sslmode=disable"
logging:
level: "info"
format: "json"
To enable TLS/STARTTLS for SMTP and IMAP servers:
- Generate or obtain SSL/TLS certificates
- Update the configuration with certificate paths in the
server.tls
section - Enable TLS for specific services:
- Set
server.smtp.msa.tls: true
for SMTP MSA (port 587) - Set
server.smtp.mta.tls: true
for SMTP MTA (port 25) - Set
server.imap.tls: true
for IMAP (port 1143)
- Set
- Set
allow_insecure_auth: false
to require encrypted connections for authentication
Example TLS-enabled configuration:
server:
smtp:
allow_insecure_auth: false
msa:
tls: true
imap:
tls: true
allow_insecure_auth: false
tls:
cert_file: "/etc/ssl/certs/mail.example.com.crt"
key_file: "/etc/ssl/private/mail.example.com.key"
Create a Project:
curl -X POST http://localhost:8080/api/projects \
-H "Content-Type: application/json" \
-d '{"name": "Test Project"}'
Create an Inbox:
curl -X POST http://localhost:8080/api/projects/1/inboxes \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'
Create a Rule:
curl -X POST http://localhost:8080/api/projects/1/inboxes/1/rules \
-H "Content-Type: application/json" \
-d '{
"sender": "[email protected]",
"receiver": "[email protected]",
"subject": "Test Subject"
}'
Using SWAKS:
swaks --to [email protected] \
--from [email protected] \
--server localhost:1025 \
--header "Subject: Test Subject" \
--body "This is a test email."
.
├── cmd/ # Application entry points
├── frontend/ # Vue.js frontend application
├── internal/ # Internal packages
│ ├── api/ # HTTP API implementation
│ ├── core/ # Business logic
│ ├── smtp/ # SMTP server
│ ├── imap/ # IMAP server
│ ├── migrations/ # Database migrations
│ ├── storage/ # Database repositories
│ └── models/ # Database models
└── bruno/ # API test collections