Troubleshooting
Common issues and solutions for Mailtura
This guide covers common issues you might encounter when using Mailtura and how to resolve them.
Installation Issues
Docker Services Won’t Start
Problem: Services fail to start with Docker Compose.
Solution:
- Check Docker logs:
docker-compose logs - Verify port availability:
lsof -i :587 # Check SMTP port lsof -i :5432 # Check PostgreSQL port - Ensure sufficient disk space:
df -h
Database Connection Errors
Problem: Cannot connect to the database.
Solution:
- Verify database is running:
docker-compose ps postgres - Check connection string in
.env:DATABASE_URL=postgresql://user:password@localhost:5432/mailtura - Test database connection:
psql $DATABASE_URL
Email Delivery Issues
Emails Not Sending
Problem: Emails are queued but not being sent.
Solution:
- Check SMTP configuration:
curl https://your-mailtura-instance.com/api/v1/health - Verify SMTP credentials
- Check firewall rules for outbound SMTP
- Review email queue:
curl https://your-mailtura-instance.com/api/v1/queue \ -H "Authorization: Bearer YOUR_API_KEY"
Emails Going to Spam
Problem: Sent emails are marked as spam.
Solution:
- Set up SPF record:
v=spf1 include:your-mailtura-instance.com ~all - Configure DKIM signing
- Add DMARC policy:
v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com - Use a verified domain
- Maintain good sender reputation
High Bounce Rate
Problem: Many emails are bouncing.
Solution:
- Validate email addresses before sending
- Clean your email list regularly
- Check bounce reasons:
curl https://your-mailtura-instance.com/api/v1/bounces \ -H "Authorization: Bearer YOUR_API_KEY" - Remove hard bounces from your list
- Implement double opt-in for subscriptions
API Issues
Authentication Errors
Problem: Getting 401 Unauthorized responses.
Solution:
- Verify API key is valid:
echo $MAILTURA_API_KEY - Check tenant ID header:
X-Tenant-ID: your-tenant-id - Ensure API key has correct permissions
- Check if API key is expired
Rate Limiting
Problem: Receiving 429 Too Many Requests errors.
Solution:
- Check current rate limits:
curl https://your-mailtura-instance.com/api/v1/quotas \ -H "Authorization: Bearer YOUR_API_KEY" - Implement exponential backoff
- Use bulk endpoints for multiple emails
- Request quota increase if needed
Template Not Found
Problem: API returns template not found error.
Solution:
- List available templates:
curl https://your-mailtura-instance.com/api/v1/templates \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "X-Tenant-ID: your-tenant-id" - Verify template name matches exactly
- Check tenant ID is correct
- Ensure template is published
Performance Issues
Slow Email Delivery
Problem: Emails take a long time to deliver.
Solution:
- Check queue depth:
curl https://your-mailtura-instance.com/api/v1/metrics/queue - Scale worker processes
- Optimize database queries
- Check network latency to SMTP server
- Review rate limiting settings
High Memory Usage
Problem: Mailtura consuming excessive memory.
Solution:
- Monitor memory usage:
docker stats - Reduce batch sizes for bulk operations
- Optimize template sizes
- Increase available memory
- Check for memory leaks in logs
Monitoring and Debugging
Enable Debug Logging
Add to your .env file:
LOG_LEVEL=debug
DEBUG=mailtura:*
Check Application Logs
docker-compose logs -f mailtura
Monitor System Health
curl https://your-mailtura-instance.com/api/v1/health \
-H "Authorization: Bearer YOUR_API_KEY"
Expected response:
{
"status": "healthy",
"services": {
"database": "up",
"smtp": "up",
"queue": "up"
}
}
Database Performance
Monitor slow queries:
SELECT * FROM pg_stat_statements
ORDER BY total_time DESC
LIMIT 10;
Common Error Codes
| Code | Meaning | Solution |
|---|---|---|
| 400 | Bad Request | Check request payload format |
| 401 | Unauthorized | Verify API key and headers |
| 403 | Forbidden | Check tenant permissions |
| 404 | Not Found | Verify resource exists |
| 429 | Rate Limited | Implement backoff, check quotas |
| 500 | Server Error | Check server logs, contact support |
Getting Help
If you’re still experiencing issues:
- Check the documentation: Review relevant docs sections
- Search existing issues: GitHub Issues
- Ask the community: Join discussions on GitHub
- Create an issue: Provide:
- Mailtura version
- Environment details
- Error messages
- Steps to reproduce
- Relevant logs
Useful Commands
Reset Everything
docker-compose down -v
docker-compose up -d
View Real-time Logs
docker-compose logs -f --tail=100
Check Configuration
docker-compose exec mailtura cat /etc/mailtura/config.yml
Database Backup
docker-compose exec postgres pg_dump -U postgres mailtura > backup.sql
Database Restore
docker-compose exec -T postgres psql -U postgres mailtura < backup.sql