To make the campaign email sending work, please add the following environment variables to your .env.local file:
# SMTP Settings SMTP_HOST=your-smtp-server.com SMTP_PORT=587 SMTP_USER=your-smtp-username SMTP_PASS=your-smtp-password SMTP_SECURE=false # Set to true for port 465 # Email API Security EMAIL_API_SECRET=lystica-email-secret # Change this in production to a secure random string # Email Display Settings EMAIL_FROM=hello@yourdomain.com EMAIL_FROM_NAME=Lystica
Testing Options:
1. For development testing (no real emails sent):
- Leave these variables unset, and the system will use Ethereal mail which captures emails but doesn't actually send them
- Check the console logs to see URLs where you can view the test emails
2. For Gmail testing:
SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your-gmail@gmail.com SMTP_PASS=your-app-password # Use an App Password, not your regular password SMTP_SECURE=false
Note: You need to create an App Password in your Google Account if using Gmail.
3. For other email providers like SendGrid, Mailgun, etc.:
- Use their SMTP settings as provided in their documentation
After adding these variables, restart your development server for the changes to take effect.
Common Email Providers
Gmail
- Host: smtp.gmail.com
- Port: 587
- Requires App Password
Outlook
- Host: smtp.office365.com
- Port: 587
- May require App Password
Yahoo
- Host: smtp.mail.yahoo.com
- Port: 587
- Requires App Password
SendGrid
- Host: smtp.sendgrid.net
- Port: 587
- Uses API Key as password
Troubleshooting
Authentication Failed
Make sure you're using an App Password instead of your regular password for Gmail, Yahoo, and other providers with 2FA enabled.
Connection Timeout
Check your SMTP host and port settings. Port 587 is typically used for TLS, while port 465 is for SSL.
Emails Not Sending
Verify all environment variables are set correctly and restart your development server after making changes.
Security Best Practices
- Never commit your email credentials to version control
- Use environment variables for all sensitive configuration
- Generate unique App Passwords for this application
- Regularly rotate your email passwords and API keys
- Use a dedicated email account for sending campaigns
- Monitor your email sending limits and quotas