Get Elastic Email SMTP Credentials
Before configuring Exim, ensure you have:
Elastic Email’s SMTP server address: Typically smtp.elasticemail.com.
SMTP port: Usually 2525, 587 (STARTTLS), or 465 (SMTPS).
Elastic Email username: This is typically your Elastic Email account email.
Elastic Email API key: Acts as the SMTP password.
Update Exim Configuration
The exact location of Exim’s configuration files may vary by system. On most systems:
Debian-based: /etc/exim4/exim4.conf.template or split configurations in /etc/exim4/conf.d/
Red Hat-based: /etc/exim/exim.conf
You need to modify or add sections for routing and authenticating with Elastic Email.
a. Configure Authentication
Add the SMTP authentication details under the authenticators section:
plaintext
Copy code
remote_smtp_auth:
driver = plaintext
public_name = LOGIN
client_send = : <YOUR_ELASTIC_EMAIL_USERNAME> : <YOUR_ELASTIC_EMAIL_API_KEY>
b. Set Up the Transport
Under the transports section, configure the relay transport for Elastic Email:
plaintext
Copy code
remote_smtp:
driver = smtp
port = 587 # Use 2525 or 465 if preferred.
hosts_require_auth = *
hosts_require_tls = *
Port options:
For 465, use implicit TLS (tls_on_connect_ports = 465).
For 587 or 2525, STARTTLS will be used if hosts_require_tls = * is enabled.
c. Define the Router
In the routers section, direct all outgoing emails through Elastic Email:
plaintext
Copy code
send_via_elasticemail:
driver = manualroute
domains = ! +local_domains
transport = remote_smtp
route_list = * smtp.elasticemail.com
This tells Exim to route all emails (except local domains) through Elastic Email.
Restart Exim
After making changes, restart Exim to apply the new configuration:
bash
Copy code
sudo systemctl restart exim4
Test the setup
Send a test email using the mail command or another client:
bash
Copy code
echo "Test email via Elastic Email" | mail -s "Test Email" recipient@example.com
Check the logs (usually in /var/log/exim4/mainlog or /var/log/exim/mainlog) for successful submission:
bash
Copy code
sudo tail -f /var/log/exim4/mainlog
Optional Configurations
a. Set Default Sender Address
If Elastic Email requires a verified "from" address, set a default sender:
plaintext
Copy code
headers_add = From: yourname@example.com
b. Handle Bounce Emails
Elastic Email supports bounce management. Ensure your reply-to and Return-Path headers are correctly configured to monitor bounces.
c. Rate Limiting
To comply with Elastic Email’s sending limits, configure Exim to throttle outgoing emails:
plaintext
Copy code
smtp_accept_queue_per_connection = 20
smtp_accept_max_per_host = 100
Troubleshooting
Authentication Errors: Verify your Elastic Email username and API key.
TLS Issues: Confirm the certificate validity for smtp.elasticemail.com.
Routing Problems: Check the router and transport configuration for typos.
Monitoring
Use Elastic Email's dashboard to monitor:
Email delivery statistics.
Bounce and complaint rates.
API and SMTP usage.
This configuration ensures Exim works seamlessly with Elastic Email for sending messages securely and efficiently.