Setting up an SMTP Server
Overview
This project was implemented on a Raspberry Pi 3B+ using Docker and Mailcow, incorporating Dovecot for IMAP & POP3 Email Retrieval, and Postfix for handling SMTP requests.
After evaluating various options, Mailcow emerged as the most suitable solution due to its comprehensive integration of essential mail server components. The deployment process via Docker was streamlined, requiring minimal setup configuration.
DNS Configuration
SPF Record
Configured to specify authorized IP addresses that can send emails from the domain:
DKIM Record
Implemented for email authentication using public/private key pair:
DMARC Record
Enforced strict email authentication policies with immediate rejection for SPF/DKIM failures:
Implementation Challenges
Residential IP Blocklisting
The server's residential IP address was initially blocklisted by Spamhaus, as residential IPs are not typically expected to host mail servers. This was resolved through a successful exclusion request process.
Reverse DNS Limitations
ISP restrictions prevented the setup of reverse DNS records, significantly impacting email deliverability. This resulted in major email clients (Gmail, Outlook) marking messages as spam.
SMTP Protocol Analysis
During testing, interesting observations were made regarding email header manipulation and transport behavior. Below is an example SMTP request demonstrating the dual occurrence of sender/recipient information:
This example highlights how sender and recipient information appears twice: once in the envelope (MAIL FROM & RCPT TO) and again in the message headers (From & To fields).
Key Findings
Email Transport Behavior
- Only envelope headers (MAIL FROM & RCPT TO) are used for actual mail transport
- Header fields under DATA section can be manipulated within DKIM/DMARC constraints
- Some mail servers can be configured to enforce envelope-header matching, though this may affect CC functionality
Delivery Success Conditions
- Emails were delivered (marked as spam) when:
- From field contained any email from gibibyte.org domain (valid or not)
- To field could be arbitrarily set without affecting delivery