SMTP Configuration
Setting up a reliable SMTP server is crucial for successful email delivery. This guide covers both local development and production configurations.
💡 Pro Tip: For production, use a dedicated email service provider (ESP) like SendGrid, AWS SES, or Mailgun for better deliverability.
SMTP Options
Development (Built-in)
Use DripEmails.org's built-in SMTP server for testing locally
Production (ESP)
Use SendGrid, AWS SES, Mailgun, or similar for sending at scale
Self-Hosted
Configure Postfix or similar on your own server (advanced)
Using Built-in SMTP (Development)
- The built-in SMTP server is already included
- No configuration needed for local testing
- Emails are logged but not actually sent
- Perfect for development and testing
Configuring External SMTP
Add to your .env file or environment variables:
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.sendgrid.net
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=apikey
EMAIL_HOST_PASSWORD=your-sendgrid-api-key
DEFAULT_FROM_EMAIL=noreply@yourdomain.com
SendGrid Setup
- Create account at sendgrid.com
- Verify your domain or sender email
- Generate an API key in settings
- Add credentials to your .env file
- Test with a sample email
⚠️ Important: Never commit API keys to version control. Always use environment variables.
AWS SES Setup
Amazon Simple Email Service configuration:
EMAIL_HOST=email-smtp.us-east-1.amazonaws.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-ses-smtp-username
EMAIL_HOST_PASSWORD=your-ses-smtp-password
AWS_SES_REGION_NAME=us-east-1
AWS_SES_REGION_ENDPOINT=email.us-east-1.amazonaws.com
Mailgun Setup
EMAIL_HOST=smtp.mailgun.org
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=postmaster@yourdomain.mailgun.org
EMAIL_HOST_PASSWORD=your-mailgun-smtp-password
Testing SMTP Configuration
Run this Django management command:
from django.core.mail import send_mail
send_mail(
'Test Subject',
'Test message',
'from@example.com',
['to@example.com'],
fail_silently=False,
)
Domain Authentication
Required for good deliverability:
- SPF Record: Authorizes servers to send on your behalf
- DKIM: Cryptographic signature proving email authenticity
- DMARC: Policy for handling failed authentication
- Custom Domain: Send from @yourdomain.com, not @gmail.com
Email Sending Limits
Know your provider's limits:
Troubleshooting
Connection Refused
Check firewall settings, verify SMTP host and port are correct
Authentication Failed
Double-check credentials, regenerate API key if needed
Emails to Spam
Configure SPF, DKIM, DMARC properly. Warm up your domain gradually
Monitoring Email Delivery
- Track delivery rates in ESP dashboard
- Monitor bounce rates (keep under 2%)
- Watch spam complaint rates (keep under 0.1%)
- Set up webhook notifications for failures
- Review sending reputation scores regularly
Best Practices
- Use TLS/SSL encryption (port 587 or 465)
- Never send from @gmail.com or @yahoo.com in production
- Authenticate your domain properly
- Start with low sending volumes and gradually increase
- Monitor deliverability metrics closely
- Keep your bounce list clean
- Use different SMTP configs for dev/staging/production