Environment Variables
CAFH Platform uses environment variables for configuration. Create a.env file in the project root to customize your instance.
Required Variables
SMTP Configuration
Email functionality requires SMTP server configuration:.env
Your SMTP server hostnameExamples:
- cPanel:
mail.yourdomain.com - Gmail:
smtp.gmail.com - SendGrid:
smtp.sendgrid.net - Mailgun:
smtp.mailgun.org
SMTP server portCommon ports:
465- SSL/TLS (recommended)587- STARTTLS25- Unencrypted (not recommended)
SMTP authentication username (usually an email address)
SMTP authentication password
Enable SSL/TLS encryption
true- Use SSL/TLS (port 465)false- Use STARTTLS (port 587)
Maximum emails to send per hour (throttling)Prevents hitting provider limits and maintains good sender reputation.
SMTP Provider Examples
- cPanel
- Gmail
- SendGrid
- Mailgun
.env
Development vs Production
Development (.env.local)
.env.local
Production (.env.production)
.env.production
Verification
Test your SMTP configuration:Environment Variable Loading
The platform usesdotenv to load environment variables from .env:
server.ts
Troubleshooting
SMTP connection timeout
SMTP connection timeout
- Verify your SMTP host and port are correct
- Check if your firewall allows outbound connections on the SMTP port
- Some ISPs block port 25; use port 587 or 465 instead
Authentication failed
Authentication failed
- Double-check your username and password
- For Gmail, ensure you’re using an App Password, not your regular password
- For other providers, verify your credentials in their dashboard
Emails not sending
Emails not sending
- Check the email queue status at
/api/email/status - Review the console for error messages
- Verify you haven’t exceeded
MAX_EMAILS_PER_HOUR - Check the
data.jsonfile for queued emails
Next Steps
Running Locally
Learn about development workflows
Email Server
Understand the email queue system
SMTP Configuration
Admin guide for SMTP setup
Deployment
Deploy to production