Skip to content
Display

Display

Star12.2k

Self-hosting

Email and SMTP configuration

  • Self-hosted only

At a glance

TimeAbout 15 min

LevelSome experience

You need

  • SMTP details from your email provider: server, port, username and password (an app password for Gmail with 2-Step Verification)
  • The address Leantime sends from

Where you'll work

  1. Your email provider's settings, for the SMTP details
  2. Leantime's config/.env file, or the container's environment
  3. A terminal on your server, to send a test email

At the end

Leantime sending invitations, password resets and notifications through your mail server, confirmed with a test email.

Markdown

Leantime uses email for user invitations, password resets, notifications, and project updates. This guide covers how to configure email correctly and troubleshoot common issues.

Leantime supports two methods for sending email:

Method Pros Cons
SMTP (Recommended) Better deliverability, more reliable, detailed error logging Requires SMTP credentials
PHP mail() Simpler setup, no credentials needed Often blocked by hosts, poor deliverability

Quick Start: Common Provider Configurations

Section titled “Quick Start: Common Provider Configurations”
LEAN_EMAIL_RETURN='your-email@gmail.com'
LEAN_EMAIL_USE_SMTP=true
LEAN_EMAIL_SMTP_HOSTS='smtp.gmail.com'
LEAN_EMAIL_SMTP_AUTH=true
LEAN_EMAIL_SMTP_USERNAME='your-email@gmail.com'
LEAN_EMAIL_SMTP_PASSWORD='your-app-password'
LEAN_EMAIL_SMTP_AUTO_TLS=true
LEAN_EMAIL_SMTP_SECURE='tls'
LEAN_EMAIL_SMTP_PORT='587'
LEAN_EMAIL_RETURN='your-email@yourdomain.com'
LEAN_EMAIL_USE_SMTP=true
LEAN_EMAIL_SMTP_HOSTS='smtp.office365.com'
LEAN_EMAIL_SMTP_AUTH=true
LEAN_EMAIL_SMTP_USERNAME='your-email@yourdomain.com'
LEAN_EMAIL_SMTP_PASSWORD='your-password'
LEAN_EMAIL_SMTP_AUTO_TLS=true
LEAN_EMAIL_SMTP_SECURE='tls'
LEAN_EMAIL_SMTP_PORT='587'
LEAN_EMAIL_RETURN='noreply@yourdomain.com'
LEAN_EMAIL_USE_SMTP=true
LEAN_EMAIL_SMTP_HOSTS='smtp.sendgrid.net'
LEAN_EMAIL_SMTP_AUTH=true
LEAN_EMAIL_SMTP_USERNAME='apikey'
LEAN_EMAIL_SMTP_PASSWORD='your-sendgrid-api-key'
LEAN_EMAIL_SMTP_AUTO_TLS=true
LEAN_EMAIL_SMTP_SECURE='tls'
LEAN_EMAIL_SMTP_PORT='587'
LEAN_EMAIL_RETURN='noreply@yourdomain.com'
LEAN_EMAIL_USE_SMTP=true
LEAN_EMAIL_SMTP_HOSTS='smtp.mailgun.org'
LEAN_EMAIL_SMTP_AUTH=true
LEAN_EMAIL_SMTP_USERNAME='postmaster@yourdomain.com'
LEAN_EMAIL_SMTP_PASSWORD='your-mailgun-password'
LEAN_EMAIL_SMTP_AUTO_TLS=true
LEAN_EMAIL_SMTP_SECURE='tls'
LEAN_EMAIL_SMTP_PORT='587'
LEAN_EMAIL_RETURN='noreply@yourdomain.com'
LEAN_EMAIL_USE_SMTP=true
LEAN_EMAIL_SMTP_HOSTS='email-smtp.us-east-1.amazonaws.com'
LEAN_EMAIL_SMTP_AUTH=true
LEAN_EMAIL_SMTP_USERNAME='your-ses-smtp-username'
LEAN_EMAIL_SMTP_PASSWORD='your-ses-smtp-password'
LEAN_EMAIL_SMTP_AUTO_TLS=true
LEAN_EMAIL_SMTP_SECURE='tls'
LEAN_EMAIL_SMTP_PORT='587'

This is the most common source of configuration issues. Use the following combinations:

Port Security Setting Protocol When to Use
587 LEAN_EMAIL_SMTP_SECURE='tls' STARTTLS Most modern providers (recommended)
465 LEAN_EMAIL_SMTP_SECURE='ssl' Implicit SSL Older providers, legacy systems
25 LEAN_EMAIL_SMTP_SECURE='' None Unencrypted (not recommended, often blocked)
2525 LEAN_EMAIL_SMTP_SECURE='tls' STARTTLS Alternative when 587 is blocked

Both STARTTLS and SSL encrypt the connection. They only differ in when the encryption starts, so use the pair your provider names.

Common mistake: Using port 465 with tls, or port 587 with ssl. These are not interchangeable—each port expects a specific security protocol.

## Required Settings
LEAN_EMAIL_RETURN='noreply@yourdomain.com' # From address for all outgoing emails
LEAN_EMAIL_USE_SMTP=true # true = use SMTP, false = use PHP mail()
## SMTP Server Settings
LEAN_EMAIL_SMTP_HOSTS='smtp.example.com' # Your SMTP server hostname
LEAN_EMAIL_SMTP_PORT='587' # Port number (see table above)
LEAN_EMAIL_SMTP_SECURE='tls' # Security: 'tls', 'ssl', or '' (none)
## Authentication
LEAN_EMAIL_SMTP_AUTH=true # Enable authentication (most servers require this)
LEAN_EMAIL_SMTP_USERNAME='your-username' # Usually your full email address
LEAN_EMAIL_SMTP_PASSWORD='your-password' # Password or app-specific password
## Optional Settings
LEAN_EMAIL_SMTP_AUTO_TLS=true # Auto-upgrade to TLS if available
LEAN_EMAIL_SMTP_SSLNOVERIFY=false # Set to true only for self-signed certificates

Use the built-in test command to verify your email configuration:

Terminal window
# For Docker installations
docker exec -it leantime php ./bin/leantime email:testemail --address="test@example.com"
# For package installations, as the web server user
cd /var/www/html # or your Leantime directory
sudo -u www-data php ./bin/leantime email:testemail --address="test@example.com"
  1. Go to Company → User Management
  2. Click Invite User
  3. Enter an email address you can access
  4. Check if the invitation email arrives

Add this to your .env file to see detailed email logs:

LEAN_DEBUG=1
  • Docker: Run docker logs leantime or check inside container at /var/www/html/storage/logs/
  • Package install: Check /var/www/html/storage/logs/leantime-YYYY-MM-DD.log

Watch logs in real-time while testing:

Terminal window
# Docker
docker exec -it leantime tail -f /var/www/html/storage/logs/leantime-$(date +%Y-%m-%d).log
# Package install
tail -f /var/www/html/storage/logs/leantime-$(date +%Y-%m-%d).log

Possible causes:

  • Wrong port/security combination
  • Firewall blocking outbound connections
  • Incorrect hostname

Solutions:

  1. Verify you’re using the correct port and security combination (see table above)
  2. Try switching from port 465/SSL to port 587/TLS (or vice versa)
  3. Test if the port is reachable: telnet smtp.example.com 587

Check:

  1. Recipient’s spam/junk folder
  2. Your domain’s SPF and DKIM records. These are settings at your domain’s DNS provider that prove your mail server may send email for your domain; your email provider tells you what to add.
  3. Whether the SMTP provider requires domain verification

Possible causes:

  • Firewall blocking the SMTP port
  • Incorrect hostname
  • VPS provider blocking SMTP (common with budget hosting)

Solutions:

  1. Contact your hosting provider about SMTP restrictions
  2. Use an external SMTP service (SendGrid, Mailgun, etc.)
  3. Try port 2525 as an alternative

For Docker installations:

Terminal window
docker compose down
docker compose up -d

For package installations:

Terminal window
# Clear any cached configuration (as the web server user, so new cache files don't belong to root)
sudo -u www-data php ./bin/leantime cache:clearAll
# Restart PHP-FPM (adjust version as needed)
sudo systemctl restart php8.2-fpm

In Docker, list the email settings the container started with:

Terminal window
docker exec -it leantime printenv | grep LEAN_EMAIL

On a package install, Leantime reads config/.env itself, so the shell doesn’t show these settings. Run the test email instead (see Method 1: CLI Test Email). It prints the whole conversation with your mail server, including the server name, port and any error.

Many shared hosting providers restrict or block SMTP connections. Options include:

  1. Use the host’s built-in SMTP — Check your hosting control panel (cPanel, Plesk) for email routing settings
  2. Use an external SMTP service — SendGrid, Mailgun, and Postmark offer free tiers that work around hosting restrictions
  3. Fall back to PHP mail() — Set LEAN_EMAIL_USE_SMTP=false (less reliable but may work)

Leantime puts notification emails in a queue, and its scheduled jobs send them every minute. Each person’s Email frequency also collects changes into one email (see Notifications). If emails come late or not at all:

  • Check that the scheduled jobs run. Set up the cron job in How do I run the scheduled jobs?. Without it, emails only go out while someone has Leantime open. The official Docker image runs the jobs for you.
  • Check the queue with the scheduler: php ./bin/leantime schedule:list shows queue:emails and when it runs next.

Test emails from email:testemail are sent right away, not queued.

If you’re still having issues after trying the troubleshooting steps above:

  1. Check the Common Problems page
  2. Search the GitHub Issues
  3. Ask in the Discord Community #self-hosted channel

When asking for help, please include:

  • Your email configuration (with passwords redacted)
  • The error message from the logs
  • Your hosting environment (Docker, shared hosting, VPS, etc.)

Was this page helpful?