GreenMail Email Server
GreenMail is a local email server used for development and testing. It captures all outbound emails without actually sending them, making it ideal for testing email functionality in dev environments.
Overview
GreenMail provides:
-
SMTP server for sending emails
-
POP3 and IMAP servers for retrieving emails
-
REST API for programmatic access to messages
-
No authentication required (disabled for dev use)
-
No external dependencies
Kubernetes Deployment
GreenMail is deployed to the event-dev namespace using raw Kubernetes manifests (not a Helm chart).
Deployment Files
Located in the infrastructure repository under event-membership/greenmail-dev/:
apiVersion: apps/v1
kind: Deployment
metadata:
name: greenmail
labels:
app: greenmail
spec:
replicas: 1
selector:
matchLabels:
app: greenmail
template:
spec:
containers:
- name: greenmail
image: greenmail/standalone:latest
env:
- name: GREENMAIL_OPTS
value: '-Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.smtp.port=25 -Dgreenmail.pop3.port=110 -Dgreenmail.imap.port=143 -Dgreenmail.api.port=8080'
ports:
- name: http
containerPort: 8080
- name: smtp
containerPort: 25
- name: pop3
containerPort: 110
- name: imap
containerPort: 143
apiVersion: v1
kind: Service
metadata:
name: greenmail
spec:
selector:
app: greenmail
type: ClusterIP
ports:
- name: http
port: 8080
- name: smtp
port: 25
- name: pop3
port: 110
- name: imap
port: 143
ArgoCD Application
GreenMail is deployed via ArgoCD using a Git source (not OCI Helm):
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: greenmail-dev
namespace: argocd
spec:
project: default
destination:
name: idl-xnl-jhb1-rc01
namespace: event-dev
source:
repoURL: [email protected]:christhonie/idl-xnl-jhb-rc01.git
targetRevision: HEAD
path: event-membership/greenmail-dev
syncPolicy:
automated:
prune: true
selfHeal: true
Exposed Ports
| Port | Protocol | Purpose |
|---|---|---|
25 |
SMTP |
Send emails |
110 |
POP3 |
Retrieve emails (POP3 protocol) |
143 |
IMAP |
Retrieve emails (IMAP protocol) |
8080 |
HTTP |
REST API and web interface |
Integrating with Applications
Kubernetes Service DNS
Within the cluster, applications connect to GreenMail using its service DNS name:
greenmail.event-dev.svc.cluster.local
Application Configuration
Configure Spring Boot applications to use GreenMail in dev deployments:
config:
mail:
host: greenmail.event-dev.svc.cluster.local
port: 25
from: [email protected]
username: ""
password: ""
protocol: smtp
tls: false
properties.mail.smtp:
auth: false
starttls.enable: false
Key settings:
-
No authentication:
usernameandpasswordare empty,auth: false -
No TLS:
tls: falseandstarttls.enable: false -
Standard SMTP port: Port 25 (GreenMail configured with
-Dgreenmail.smtp.port=25)
Viewing Captured Emails
REST API
GreenMail provides a REST API on port 8080 for accessing captured messages:
curl http://greenmail.event-dev.svc.cluster.local:8080/api/mail
curl http://greenmail.event-dev.svc.cluster.local:8080/api/mail/count
curl -X DELETE http://greenmail.event-dev.svc.cluster.local:8080/api/mail
Port Forwarding for Local Access
To access GreenMail from your local machine:
kubectl port-forward -n event-dev svc/greenmail 8080:8080 25:25
Then access the API at http://localhost:8080/api/mail.
Common Issues
Connection Refused
-
Verify GreenMail pod is running:
kubectl get pods -n event-dev -l app=greenmail -
Check pod logs:
kubectl logs -n event-dev -l app=greenmail -
Ensure correct service DNS name is used
SnappyMail Web Client
SnappyMail is a lightweight, modern web-based email client deployed alongside GreenMail for viewing and composing test emails.
Overview
SnappyMail provides:
-
Web-based email interface for IMAP/SMTP
-
Easy account switching (no pre-registration required)
-
Compose and send test emails
-
View emails received by any test account
Kubernetes Deployment
SnappyMail is deployed to the event-dev namespace using raw Kubernetes manifests.
Deployment Files
Located in the infrastructure repository under event-membership/snappymail-dev/:
-
configmap.yml- Domain configuration pointing to GreenMail -
deployment.yml- SnappyMail container deployment -
service.yml- ClusterIP service on port 8888
ArgoCD Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: snappymail-dev
namespace: argocd
spec:
project: default
destination:
name: idl-xnl-jhb1-rc01
namespace: event-dev
source:
repoURL: [email protected]:christhonie/idl-xnl-jhb-rc01.git
targetRevision: HEAD
path: event-membership/snappymail-dev
Accessing SnappyMail
Port Forwarding
To access SnappyMail from your local machine:
kubectl port-forward -n event-dev svc/snappymail 8888:8888
Then open http://localhost:8888 in your browser.
Logging In
GreenMail automatically creates mailboxes when emails are received. To log in to SnappyMail:
-
Enter any email address (e.g.,
[email protected],[email protected]) -
Enter any password (GreenMail has authentication disabled)
-
The domain should be
greenmail(pre-configured)
This allows easy switching between different test user accounts without any pre-registration.
Sending Test Emails
Use SnappyMail to compose and send emails between test accounts:
-
Log in as one user (e.g.,
[email protected]) -
Compose an email to another address (e.g.,
[email protected]) -
Send the email (captured by GreenMail)
-
Log out and log in as
[email protected]to view the received email
Admin Panel
SnappyMail includes an admin panel for configuration:
-
Username:
admin -
Password:
admin123
| The admin panel is primarily for troubleshooting. Most configuration is managed via the ConfigMap. |
Common Issues
Cannot Connect to Mail Server
-
Verify GreenMail pod is running:
kubectl get pods -n event-dev -l app=greenmail -
Check SnappyMail logs:
kubectl logs -n event-dev -l app=snappymail -
Ensure GreenMail service is accessible from SnappyMail pod