SMTP Configuration
SMTP (Simple Mail Transfer Protocol) configuration enables the platform to send emails for campaigns, automations, and system notifications.Environment Variables
SMTP settings are configured via environment variables in.env file.
Configuration Example
From.env.example:lines 1-10:
Variable Definitions
| Variable | Description | Example |
|---|---|---|
SMTP_HOST | Mail server hostname | mail.yourdomain.com |
SMTP_PORT | SMTP port (465 for SSL, 587 for TLS) | 465 |
SMTP_USER | Email account username | [email protected] |
SMTP_PASS | Email account password | your_password |
SMTP_SECURE | Enable SSL/TLS encryption | true |
MAX_EMAILS_PER_HOUR | Hourly sending limit | 80 |
SMTP Transporter
The server creates a Nodemailer transporter using these settings. Fromserver.ts:lines 54-62:
Provider-Specific Setup
cPanel Email
Recommended for shared hosting:Most cPanel hosts limit to 100 emails/hour. Set
MAX_EMAILS_PER_HOUR=80 to stay below the limit with buffer.Gmail / Google Workspace
SendGrid
Mailgun
Rate Limiting System
The platform implements hourly throttling to prevent SMTP provider rate limit violations.How It Works
Fromserver.ts:lines 116-169:
Queue Status API
Monitor queue health via REST endpoint: Endpoint:GET /api/email/status
Response:
server.ts:lines 99-112.
Email Queue Database
Emails are stored in a JSON file-based queue (production systems should use MySQL/PostgreSQL). Fromserver.ts:lines 26-34:
data.json in server root directory.
Sending Emails Programmatically
Add to Queue
Endpoint:POST /api/email/queue
Request Body:
server.ts:lines 72-96.
Internal CRM Usage
The CRM interface calls this endpoint:Testing SMTP Configuration
Test with Campaign
- Create a test campaign
- Set recipient type to βAllβ
- Send test email to your address
- Check inbox and spam folder
Monitor Queue
Navigate to CRM β View queue status badge.Should show:
pending: 1- After 30s max:
sent: 1
Troubleshooting
Authentication Failed
Error:Invalid login: 535 Authentication failed
Solutions:
- Verify
SMTP_USERandSMTP_PASSare correct - For Gmail: Use App Password, not account password
- Check provider requires username vs full email address
Connection Timeout
Error:ETIMEDOUT or ECONNREFUSED
Solutions:
- Verify
SMTP_HOSTis reachable - Check firewall allows outbound traffic on
SMTP_PORT - Confirm port (465 for SSL, 587 for TLS)
- Try toggling
SMTP_SECURE
Rate Limit Exceeded
Error:550 Rate limit exceeded
Solutions:
- Lower
MAX_EMAILS_PER_HOURin.env - Restart server to reload environment variables
- Wait for hourly counter to reset
- Upgrade to provider with higher limits
Emails Not Sending
Check:- Queue status shows
pending > 0 sentCountThisHour < MAX_EMAILS_PER_HOUR- Server logs show worker activity
- SMTP credentials are valid
SSL/TLS Certificate Errors
Error:self signed certificate
Solutions:
- Set
SMTP_SECURE=falseand use port 587 (TLS) - Update Node.js to latest version
- Contact hosting provider for certificate issues
Security Best Practices
Rotate Passwords
Change SMTP passwords every 90 days.
Use Dedicated Account
Create a separate email account for system sending.
Enable 2FA
Use app-specific passwords with 2FA enabled on provider.
Monitor Logs
Review failed email logs for suspicious activity.
Production Recommendations
-
Replace File-Based Queue
- Use MySQL or PostgreSQL
- Implement proper job queue (Bull, BullMQ)
-
Add Redis Caching
- Cache hourly counter in Redis
- Faster than file I/O
-
Implement Webhook Tracking
- Use provider webhooks for delivery/open events
- More reliable than SMTP-only tracking
-
Scale Queue Processing
- Run multiple workers
- Distribute across server instances
-
Add Retry Logic
- Exponential backoff for failed sends
- Dead letter queue for permanent failures
Related Documentation
- Email Campaigns - Sending campaigns
- Automation Workflows - Automated email sequences
- CRM Contacts - Managing recipients