Self-hosting
Email and SMTP configuration
- Self-hosted only
At a glance
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
- Your email provider's settings, for the SMTP details
- Leantime's
config/.envfile, or the container's environment - 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.
Leantime uses email for user invitations, password resets, notifications, and project updates. This guide covers how to configure email correctly and troubleshoot common issues.
Email Methods
Section titled “Email Methods”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”Gmail / Google Workspace
Section titled “Gmail / Google Workspace”LEAN_EMAIL_RETURN='your-email@gmail.com'LEAN_EMAIL_USE_SMTP=trueLEAN_EMAIL_SMTP_HOSTS='smtp.gmail.com'LEAN_EMAIL_SMTP_AUTH=trueLEAN_EMAIL_SMTP_USERNAME='your-email@gmail.com'LEAN_EMAIL_SMTP_PASSWORD='your-app-password'LEAN_EMAIL_SMTP_AUTO_TLS=trueLEAN_EMAIL_SMTP_SECURE='tls'LEAN_EMAIL_SMTP_PORT='587'Microsoft 365 / Outlook
Section titled “Microsoft 365 / Outlook”LEAN_EMAIL_RETURN='your-email@yourdomain.com'LEAN_EMAIL_USE_SMTP=trueLEAN_EMAIL_SMTP_HOSTS='smtp.office365.com'LEAN_EMAIL_SMTP_AUTH=trueLEAN_EMAIL_SMTP_USERNAME='your-email@yourdomain.com'LEAN_EMAIL_SMTP_PASSWORD='your-password'LEAN_EMAIL_SMTP_AUTO_TLS=trueLEAN_EMAIL_SMTP_SECURE='tls'LEAN_EMAIL_SMTP_PORT='587'SendGrid
Section titled “SendGrid”LEAN_EMAIL_RETURN='noreply@yourdomain.com'LEAN_EMAIL_USE_SMTP=trueLEAN_EMAIL_SMTP_HOSTS='smtp.sendgrid.net'LEAN_EMAIL_SMTP_AUTH=trueLEAN_EMAIL_SMTP_USERNAME='apikey'LEAN_EMAIL_SMTP_PASSWORD='your-sendgrid-api-key'LEAN_EMAIL_SMTP_AUTO_TLS=trueLEAN_EMAIL_SMTP_SECURE='tls'LEAN_EMAIL_SMTP_PORT='587'Mailgun
Section titled “Mailgun”LEAN_EMAIL_RETURN='noreply@yourdomain.com'LEAN_EMAIL_USE_SMTP=trueLEAN_EMAIL_SMTP_HOSTS='smtp.mailgun.org'LEAN_EMAIL_SMTP_AUTH=trueLEAN_EMAIL_SMTP_USERNAME='postmaster@yourdomain.com'LEAN_EMAIL_SMTP_PASSWORD='your-mailgun-password'LEAN_EMAIL_SMTP_AUTO_TLS=trueLEAN_EMAIL_SMTP_SECURE='tls'LEAN_EMAIL_SMTP_PORT='587'Amazon SES
Section titled “Amazon SES”LEAN_EMAIL_RETURN='noreply@yourdomain.com'LEAN_EMAIL_USE_SMTP=trueLEAN_EMAIL_SMTP_HOSTS='email-smtp.us-east-1.amazonaws.com'LEAN_EMAIL_SMTP_AUTH=trueLEAN_EMAIL_SMTP_USERNAME='your-ses-smtp-username'LEAN_EMAIL_SMTP_PASSWORD='your-ses-smtp-password'LEAN_EMAIL_SMTP_AUTO_TLS=trueLEAN_EMAIL_SMTP_SECURE='tls'LEAN_EMAIL_SMTP_PORT='587'Port & Security Settings
Section titled “Port & Security Settings”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.
All Email Environment Variables
Section titled “All Email Environment Variables”## Required SettingsLEAN_EMAIL_RETURN='noreply@yourdomain.com' # From address for all outgoing emailsLEAN_EMAIL_USE_SMTP=true # true = use SMTP, false = use PHP mail()
## SMTP Server SettingsLEAN_EMAIL_SMTP_HOSTS='smtp.example.com' # Your SMTP server hostnameLEAN_EMAIL_SMTP_PORT='587' # Port number (see table above)LEAN_EMAIL_SMTP_SECURE='tls' # Security: 'tls', 'ssl', or '' (none)
## AuthenticationLEAN_EMAIL_SMTP_AUTH=true # Enable authentication (most servers require this)LEAN_EMAIL_SMTP_USERNAME='your-username' # Usually your full email addressLEAN_EMAIL_SMTP_PASSWORD='your-password' # Password or app-specific password
## Optional SettingsLEAN_EMAIL_SMTP_AUTO_TLS=true # Auto-upgrade to TLS if availableLEAN_EMAIL_SMTP_SSLNOVERIFY=false # Set to true only for self-signed certificatesTesting Your Configuration
Section titled “Testing Your Configuration”Method 1: CLI Test Email
Section titled “Method 1: CLI Test Email”Use the built-in test command to verify your email configuration:
# For Docker installationsdocker exec -it leantime php ./bin/leantime email:testemail --address="test@example.com"
# For package installations, as the web server usercd /var/www/html # or your Leantime directorysudo -u www-data php ./bin/leantime email:testemail --address="test@example.com"Method 2: Invite a Test User
Section titled “Method 2: Invite a Test User”- Go to Company → User Management
- Click Invite User
- Enter an email address you can access
- Check if the invitation email arrives
Troubleshooting
Section titled “Troubleshooting”Enable Debug Mode
Section titled “Enable Debug Mode”Add this to your .env file to see detailed email logs:
LEAN_DEBUG=1Finding Log Files
Section titled “Finding Log Files”- Docker: Run
docker logs leantimeor 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:
# Dockerdocker exec -it leantime tail -f /var/www/html/storage/logs/leantime-$(date +%Y-%m-%d).log
# Package installtail -f /var/www/html/storage/logs/leantime-$(date +%Y-%m-%d).logCommon Issues and Solutions
Section titled “Common Issues and Solutions”“SMTP connect() failed”
Section titled ““SMTP connect() failed””Possible causes:
- Wrong port/security combination
- Firewall blocking outbound connections
- Incorrect hostname
Solutions:
- Verify you’re using the correct port and security combination (see table above)
- Try switching from port 465/SSL to port 587/TLS (or vice versa)
- Test if the port is reachable:
telnet smtp.example.com 587
Emails Sent But Not Received
Section titled “Emails Sent But Not Received”Check:
- Recipient’s spam/junk folder
- 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.
- Whether the SMTP provider requires domain verification
“Connection timed out”
Section titled ““Connection timed out””Possible causes:
- Firewall blocking the SMTP port
- Incorrect hostname
- VPS provider blocking SMTP (common with budget hosting)
Solutions:
- Contact your hosting provider about SMTP restrictions
- Use an external SMTP service (SendGrid, Mailgun, etc.)
- Try port 2525 as an alternative
Configuration Changes Not Taking Effect
Section titled “Configuration Changes Not Taking Effect”For Docker installations:
docker compose downdocker compose up -dFor package installations:
# 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-fpmVerify Environment Variables Are Loaded
Section titled “Verify Environment Variables Are Loaded”In Docker, list the email settings the container started with:
docker exec -it leantime printenv | grep LEAN_EMAILOn 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.
Shared Hosting Notes
Section titled “Shared Hosting Notes”Many shared hosting providers restrict or block SMTP connections. Options include:
- Use the host’s built-in SMTP — Check your hosting control panel (cPanel, Plesk) for email routing settings
- Use an external SMTP service — SendGrid, Mailgun, and Postmark offer free tiers that work around hosting restrictions
- Fall back to PHP mail() — Set
LEAN_EMAIL_USE_SMTP=false(less reliable but may work)
Why do notification emails arrive late?
Section titled “Why do notification emails arrive late?”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:listshowsqueue:emailsand when it runs next.
Test emails from email:testemail are sent right away, not queued.
Need Help?
Section titled “Need Help?”If you’re still having issues after trying the troubleshooting steps above:
- Check the Common Problems page
- Search the GitHub Issues
- 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?
Thanks, glad it helped.
Thanks for telling us. What was missing?
