Overview
Sending emails directly from CircleCI containers using SMTP is not recommended due to rate limiting and deliverability issues. This article explains why direct email sending is problematic and provides recommended alternatives.
Why Direct Email Sending Fails
CircleCI runs on Amazon EC2 infrastructure, where port 25 is throttled by default. Because containers are distributed across many hosts at random, your emails will likely originate from IP addresses that have been used by other users previously. This creates two problems:
- Rate limiting from email providers due to shared IP reputation
- High probability of emails being flagged as spam
Recommended Solution
Use an external transactional email service with an API-based integration. These services are designed for reliable email delivery at scale and avoid the issues with direct SMTP sending.
Popular options include:
- SendGrid - Cloud-based email delivery service with robust API
- Mailgun - Developer-focused email API platform
These services provide reliable delivery, prevent spam filtering, and offer email tracking and analytics.
How to Implement
To send emails from your CircleCI jobs:
- Sign up for an email service provider (SendGrid, Mailgun, etc.)
- Obtain your API credentials
- Add the API key as an environment variable in CircleCI
- Use the service's API or SDK in your build steps to send emails
Comments
Article is closed for comments.