Customers were not receiving order confirmations. The shop was sending emails from local sendmail which was being blocked by mail servers as spam. 95% of emails ended up in the Spam folder or were rejected. Fix time: 2 hours.
Symptoms
- Customers complain about missing order confirmations
- Test email from Magento admin sends without error but never arrives
- In email headers:
X-Spam-Status: Yes - SPF/DKIM not configured for the domain
Diagnosis
# Check if email is leaving the server mail -s "Test" test@example.com <<< "Test body" cat /var/log/mail.log # Check domain SPF record dig TXT yourdomain.com | grep spf # Test deliverability at mail-tester.com
Solution
# Configure SMTP (e.g. SendGrid, Mailgun, Amazon SES) # Host: smtp.sendgrid.net # Port: 587 # Protocol: STARTTLS # Auth: Login # Add SPF record to DNS: # v=spf1 include:sendgrid.net ~all # Configure DKIM in SendGrid dashboard and add to DNS
Takeaways
Default PHP sendmail is not suitable for production. A dedicated SMTP service (SendGrid, Mailgun, Amazon SES) with correct SPF, DKIM and DMARC is the standard. Monitor email deliverability with tools like mail-tester.com monthly.
