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/:

deployment.yml
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
service.yml
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:

ArgoCD valuesObject (example from registration-portal)
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: username and password are empty, auth: false

  • No TLS: tls: false and starttls.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:

List all messages
curl http://greenmail.event-dev.svc.cluster.local:8080/api/mail
Get message count
curl http://greenmail.event-dev.svc.cluster.local:8080/api/mail/count
Clear all messages
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

Authentication Errors

GreenMail is configured with -Dgreenmail.auth.disabled. If you see authentication errors:

  • Verify application config has auth: false

  • Ensure username and password are empty strings, not null

  • Check starttls.enable: false is set

Emails Not Captured

  • Verify SMTP port 25 is being used (not 587 or 465)

  • Check application logs for SMTP connection errors

  • Test connectivity: kubectl exec -n event-dev <pod> — nc -zv greenmail 25

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.

Kubernetes Service DNS

Within the cluster, SnappyMail is accessible at:

snappymail.event-dev.svc.cluster.local:8888

Logging In

GreenMail automatically creates mailboxes when emails are received. To log in to SnappyMail:

  1. Enter any email address (e.g., [email protected], [email protected])

  2. Enter any password (GreenMail has authentication disabled)

  3. 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:

  1. Log in as one user (e.g., [email protected])

  2. Compose an email to another address (e.g., [email protected])

  3. Send the email (captured by GreenMail)

  4. Log out and log in as [email protected] to view the received email

Admin Panel

SnappyMail includes an admin panel for configuration:

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

Login Fails

  • GreenMail should have authentication disabled (-Dgreenmail.auth.disabled)

  • Try with domain greenmail selected

  • Any password should work; try a simple one like test

No Emails Visible

  • Emails only appear after being received by GreenMail

  • Send a test email first using the REST API or another client

  • Check that you’re logged in with the correct email address