Files
EmailHostingPlatform/QUICK_START.md
Tommy Parnell e9c35bdc8d init
2025-08-03 11:36:44 -04:00

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.commail.example.com
  • Server ports 25, 587, 465, 143, 993, 110, 995, 80, 443 accessible

Quick Installation

  1. Download the setup script:

    wget https://raw.githubusercontent.com/your-repo/setup-email-server.sh
    chmod +x setup-email-server.sh
    
  2. Run as root:

    sudo ./setup-email-server.sh
    
  3. Follow the prompts to enter:

    • Domain name (e.g., example.com)
    • Hostname (e.g., mail.example.com)
    • Admin email
    • Database password
    • PostfixAdmin setup password
  4. 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

  1. Visit: https://mail.example.com/postfixadmin/setup.php
  2. Enter the setup password you created
  3. Create admin user
  4. Login at: https://mail.example.com/postfixadmin/

3. Create Your First Domain and Mailbox

  1. In PostfixAdmin, add your domain (example.com)
  2. Create a mailbox (e.g., user@example.com)
  3. 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:

  1. Can't connect to PostfixAdmin:

    • Check Apache status: systemctl status apache2
    • Verify SSL certificate: openssl s_client -connect mail.example.com:443
  2. Email not sending:

    • Check Postfix status: systemctl status postfix
    • View logs: tail -f /var/log/mail.log
    • Test SMTP: telnet localhost 25
  3. Email not receiving:

    • Check MX record: dig MX example.com
    • Check firewall: ufw status
    • Test port 25: telnet mail.example.com 25
  4. DKIM issues:

    • Test DKIM: opendkim-testkey -d example.com -s mail -vvv
    • Check DNS: dig TXT mail._domainkey.example.com

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

  1. Keep system updated:

    apt update && apt upgrade -y
    
  2. Monitor logs regularly:

    tail -f /var/log/mail.log | grep -i error
    
  3. Backup regularly:

    ./backup-email-server.sh --include-mail
    
  4. Test SSL certificates:

    openssl x509 -in /etc/letsencrypt/live/mail.example.com/fullchain.pem -noout -dates
    
  5. Monitor disk space:

    df -h /var/mail/vhosts
    

Getting Help

  1. Run the test script: ./test-email-server.sh
  2. Check the setup log: /var/log/email-server-setup.log
  3. Use online testing tools: