CloakMailCloakMail

TTL Settings

Configure email expiration and auto-cleanup in CloakMail

TTL Settings

CloakMail automatically deletes emails after a configurable time-to-live (TTL) period. This ensures privacy and keeps the system clean.

Basic Configuration

Set the TTL using the EMAIL_TTL_SECONDS environment variable:

# 1 hour (default)
EMAIL_TTL_SECONDS=3600

Common TTL Values

DurationValue (seconds)
5 minutes300
15 minutes900
30 minutes1800
1 hour3600
2 hours7200
6 hours21600
12 hours43200
24 hours86400
7 days604800

How TTL Works

  1. On Inbox Creation — An expiration timestamp is set based on the current time + TTL
  2. Background Cleanup — A background process periodically removes expired emails
  3. On Access — Expired emails are also cleaned up when the inbox is accessed
Created At: 2024-01-15 10:00:00
TTL: 3600 seconds (1 hour)
Expires At: 2024-01-15 11:00:00

The TTL applies to the entire inbox, not individual emails. When the inbox expires, all emails within it are deleted.

Use Case Recommendations

Quick Verifications (5-15 minutes)

For one-time verification codes:

EMAIL_TTL_SECONDS=300  # 5 minutes

Testing & Development (1-2 hours)

For development and testing workflows:

EMAIL_TTL_SECONDS=3600  # 1 hour

Temporary Signups (24 hours)

For signing up to services you might need to verify later:

EMAIL_TTL_SECONDS=86400  # 24 hours

Extended Use (7 days)

For longer-term temporary email needs:

EMAIL_TTL_SECONDS=604800  # 7 days

Storage Considerations

Longer TTL values mean:

  • More storage usage
  • More emails retained in the system
  • Potentially higher memory usage

For high-traffic deployments, consider using shorter TTL values to keep resource usage low.

Monitoring

Use the health endpoint to check service status:

curl http://localhost:3000/api/health

Response:

{
  "status": "ok",
  "smtp": "connected",
  "redis": "connected",
  "uptime": 3600
}

Next Steps

On this page