SMTP Troubleshooting: Common Errors and How to Fix Them
SMTP issues are among the most common problems developers encounter when sending email. Connection failures, authentication errors, and delivery problems can usually be traced to a small set of root causes.
Understand SMTP response codes
SMTP servers return numeric status codes that indicate success or failure. Reading these codes is the first step in troubleshooting.
- 2xx β Success
- 4xx β Temporary failure (retry later)
- 5xx β Permanent failure (fix required)
Authentication failures (535, 530)
Authentication errors usually indicate incorrect credentials or an invalid authentication method.
- Verify username and password
- Ensure SMTP AUTH is enabled
- Use the correct submission port (587 or 465)
- Check that TLS is required and enabled
Connection and timeout errors
If your application cannot connect to the SMTP server, the issue is often network-related.
- Blocked ports by hosting provider or firewall
- Incorrect hostname or port
- Missing STARTTLS support
- DNS resolution failures
Relay denied (550 5.7.1)
A βrelay deniedβ error means the SMTP server refuses to send mail for the requested domain.
- Authenticate before sending
- Verify sender domain configuration
- Ensure IP or user is authorized to relay
Messages accepted but not delivered
When SMTP accepts a message but it never arrives, the problem is usually related to deliverability rather than SMTP itself.
- Check spam folders
- Review SPF, DKIM, and DMARC alignment
- Inspect bounce messages and logs
SMTP troubleshooting checklist
- Confirm correct SMTP host, port, and encryption
- Verify authentication credentials
- Check firewall and outbound port access
- Review SMTP logs and response codes
- Test with a known-good SMTP client