Postfix and Dovecot Integration for Enterprise: Advanced
Considerations
Instructor
Dr. Mohammed MOUSSA
Mathematics and computer science Department,
University Abdelhamid Ibn Badis
1
Advanced Postfix Configurations for Enterprise Use
1. Relay Host Configuration:
In some enterprises, outbound emails are routed through an external SMTP
relay (e.g., a cloud service). This ensures better email delivery and reduces the
chance of being blacklisted.
relayhost = [smtp.example.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
Save the relay credentials in /etc/postfix/sasl_passwd :
[smtp.example.com]:587 username:password
Update Postfix with:
sudo postmap /etc/postfix/sasl_passwd
2
sudo systemctl restart postfix
2. Implementing Rate Limiting:
Rate limiting prevents abuse by controlling the number of emails sent per
hour, reducing the chance of being marked as spam.
smtpd_client_message_rate_limit = 100
3. Logging and Monitoring:
Postfix logs email activity in /var/log/mail.log . Use tools like pflogsumm to
generate summaries and analyze server activity:
sudo apt install pflogsumm
sudo pflogsumm /var/log/mail.log | less
3
Advanced Dovecot Configurations for Authentication and Scalability
1. Using SASL Authentication with Dovecot:
Dovecot can act as an authentication backend for Postfix to provide secure
login mechanisms:
Modify /etc/dovecot/conf.d/10-auth.conf to allow plaintext
authentication:
disable_plaintext_auth = no
auth_mechanisms = plain login
Restart Dovecot to apply changes:
sudo systemctl restart dovecot
4
2. Mailbox Quotas Management:
Enforcing email quotas helps control disk usage. Configure it in
/etc/dovecot/conf.d/90-quota.conf :
plugin {
quota = maildir:User quota
quota_rule = *:storage=1G
}
5
Testing and Troubleshooting the System
1. SMTP, IMAP, and POP3 Testing:
Use swaks to test SMTP:
swaks --to user@example.com --from admin@example.com --server localhost --auth LOGIN --auth-user admin --auth-password password
For IMAP, use Telnet:
telnet localhost 143
a login user@example.com password
6
2. Common Issues and Solutions:
Email Stuck in Queue:
Check the queue with:
mailq
Flush the queue:
sudo postfix flush
Authentication Failures:
Inspect logs for issues:
tail -f /var/log/mail.log
7
Security Hardening and Best Practices
1. Enforcing Strong Password Policies:
Require users to use complex passwords and periodically rotate them.
2. Fail2ban for Brute Force Protection:
Install Fail2ban to block IPs after multiple failed login attempts:
sudo apt install fail2ban
Configure /etc/fail2ban/jail.local to monitor Postfix and Dovecot logs:
[postfix]
enabled = true
port = smtp
[dovecot]
enabled = true
port = imap3, pop3 8
3. Backup and Disaster Recovery Plan:
Regular backups ensure business continuity. Use tools like rsnapshot or
BorgBackup to back up email data:
sudo apt install rsnapshot
sudo rsnapshot sync
9
Project Assignment and Final Evaluation 1/2
1. Scenario-based Assignment:
Students must design and deploy a full-featured email system using
Postfix and Dovecot for a mock company.
The setup should include:
IMAP, POP3, and SMTP services.
TLS encryption and SASL authentication.
Quotas, monitoring, and rate limiting.
10
Project Assignment and Final Evaluation 2/2
2. Evaluation Criteria:
Functionality: Does the system support all core email services?
Security: Are encryption and authentication properly configured?
Scalability: Is the system prepared to handle high traffic and storage
demands?
Documentation: Clear explanation of configurations and
troubleshooting steps.
11