DripEmail.org

📬 SMTP Server Setup

Configure email sending infrastructure

⏱️ 18 min read

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)

  1. The built-in SMTP server is already included
  2. No configuration needed for local testing
  3. Emails are logged but not actually sent
  4. Perfect for development and testing

Configuring External SMTP

Add to your .env file or environment variables:

# Email Settings
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

  1. Create account at sendgrid.com
  2. Verify your domain or sender email
  3. Generate an API key in settings
  4. Add credentials to your .env file
  5. 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_BACKEND=django.core.mail.backends.smtp.EmailBackend
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_BACKEND=django.core.mail.backends.smtp.EmailBackend
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:

python manage.py shell

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:

SendGrid Free: 100 emails/day
AWS SES: 62,000 emails/month free (first year)
Mailgun: 5,000 emails/month free

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

Next Steps