4.1 KiB
4.1 KiB
Quick Start Guide
Prerequisites Checklist
Before running the setup script, ensure you have:
- Fresh Ubuntu 20.04+ or Debian 11+ server
- Root access to the server
- Domain name (e.g.,
example.com) - Subdomain for mail server (e.g.,
mail.example.com) - DNS A record:
mail.example.com→ Your server IP - DNS MX record:
example.com→mail.example.com - Server ports 25, 587, 465, 143, 993, 110, 995, 80, 443 accessible
Quick Installation
-
Download the setup script:
wget https://raw.githubusercontent.com/your-repo/setup-email-server.sh chmod +x setup-email-server.sh -
Run as root:
sudo ./setup-email-server.sh -
Follow the prompts to enter:
- Domain name (e.g.,
example.com) - Hostname (e.g.,
mail.example.com) - Admin email
- Database password
- PostfixAdmin setup password
- Domain name (e.g.,
-
Wait for completion (15-30 minutes)
Post-Installation Steps
1. Add DNS Records
Copy the DNS records displayed at the end of the script:
; SPF Record
example.com. IN TXT "v=spf1 mx ~all"
; DMARC Record
_dmarc.example.com. IN TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"
; DKIM Record (copy from script output)
mail._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=..."
2. Configure PostfixAdmin
- Visit:
https://mail.example.com/postfixadmin/setup.php - Enter the setup password you created
- Create admin user
- Login at:
https://mail.example.com/postfixadmin/
3. Create Your First Domain and Mailbox
- In PostfixAdmin, add your domain (
example.com) - Create a mailbox (e.g.,
user@example.com) - Test by sending an email
Testing
Run the test script:
./test-email-server.sh
Maintenance
Set up automated maintenance:
# Add to crontab
sudo crontab -e
# Add these lines:
0 2 * * * /path/to/maintenance-email-server.sh
0 5 1 * * /path/to/backup-email-server.sh
Client Configuration
IMAP Settings:
- Server: mail.example.com
- Port: 993
- Security: SSL/TLS
- Authentication: Normal password
SMTP Settings:
- Server: mail.example.com
- Port: 587
- Security: STARTTLS
- Authentication: Normal password
Troubleshooting
Common Issues:
-
Can't connect to PostfixAdmin:
- Check Apache status:
systemctl status apache2 - Verify SSL certificate:
openssl s_client -connect mail.example.com:443
- Check Apache status:
-
Email not sending:
- Check Postfix status:
systemctl status postfix - View logs:
tail -f /var/log/mail.log - Test SMTP:
telnet localhost 25
- Check Postfix status:
-
Email not receiving:
- Check MX record:
dig MX example.com - Check firewall:
ufw status - Test port 25:
telnet mail.example.com 25
- Check MX record:
-
DKIM issues:
- Test DKIM:
opendkim-testkey -d example.com -s mail -vvv - Check DNS:
dig TXT mail._domainkey.example.com
- Test DKIM:
Log Files:
- Main mail log:
/var/log/mail.log - Setup log:
/var/log/email-server-setup.log - Apache error log:
/var/log/apache2/error.log
Useful Commands:
# Check all services
systemctl status postfix dovecot amavis spamassassin clamav-daemon opendkim apache2
# Test configuration
postfix check
dovecot -n
# Check mail queue
mailq
# Flush mail queue
postqueue -f
# Check disk space
df -h
# View active connections
ss -tulpn | grep :25
Security Recommendations
-
Keep system updated:
apt update && apt upgrade -y -
Monitor logs regularly:
tail -f /var/log/mail.log | grep -i error -
Backup regularly:
./backup-email-server.sh --include-mail -
Test SSL certificates:
openssl x509 -in /etc/letsencrypt/live/mail.example.com/fullchain.pem -noout -dates -
Monitor disk space:
df -h /var/mail/vhosts
Getting Help
- Run the test script:
./test-email-server.sh - Check the setup log:
/var/log/email-server-setup.log - Use online testing tools: