Mail Server Setup
Automatic DNS with Namecheap
- In your Namecheap account open Profile, Tools, then API Access. Enable access and whitelist the public IPv4 of your VPS.
- On Set up your domain, enter your Namecheap username and API key. Choose the mail routing replacement option only if incoming mail should move away from an existing provider.
- Run Check VPS and Install. Setup publishes the two server addresses before requesting certificates, then publishes MX, SPF, DMARC, the ownership token and the actual DKIM public key. The key is used for this operation only.
- For another domain, open Domains, add its name, expand Automatic Namecheap DNS setup under it and click Configure DNS. Configure DNS automatically switches Email Forwarding to Custom MX. Its MX points to the existing TLS mail hostname. If verification is pending, wait for DNS updates and click Verify TXT and activate.
- Set reverse DNS (PTR) at your VPS provider.
Windows installer and Ubuntu server · 0.3.17
Start setup or return to an existing server
Choose I already have a VPS to set up or update your server. Choose Explore recommended VPS providers for provider links and ordering instructions, then continue with your VPS details. After signing out, click Open an existing dashboard on the welcome screen and enter your VPS password. Setup remembers the last successful connection address, port and username.
Using an existing Ubuntu 18.04 VPS
This build targets Ubuntu Server 18.04 LTS (Bionic). Start with a dedicated machine with no existing mail or web installation. You can run Installation → Check VPS on the Installation screen after entering the VPS and domain details. The report shows the OS, kernel, resources, occupied ports and Ubuntu Pro coverage. A container-based VPS must permit Docker, cgroups and its network rules. The installer obtains the Bionic Docker packages from your configured Ubuntu repositories (including Universe). It pulls the mail image and builds a separate administration and certificate runtime on the VPS. Allow outbound package access and HTTPS access to Docker Hub, GHCR and Let's Encrypt.
Canonical ended standard maintenance for 18.04 in 2023. A WARN for esm-infra or esm-apps means coverage was not confirmed; it does not stop evaluation. Check coverage and apply available security updates before running public production mail. Ubuntu 18.04 maintenance.
Choose and order a VPS
The Explore recommended VPS providers screen contains the owner's static directory. Each published entry has a short description, provider website and ordering tutorial. The initial directory is empty.
- Open the hosting provider's website. Find its VPS or cloud server plans and select a region near your intended users.
- Before ordering, ask whether its policy permits your mail traffic, whether inbound and outbound TCP 25 are available, and whether you can set PTR for your static public IPv4. A successful connection to 587 alone does not establish server-to-server delivery.
- Choose Ubuntu Server 18.04 LTS, a fresh dedicated machine, SSH password access and storage for all mail volumes. A starting point is 2–4 vCPUs, 4 GB RAM and 80 GB disk. Check snapshot coverage and charges before purchase.
- Copy the public IPv4, SSH port, account name and VPS password from the provider. For a non-root account, this installer requires passwordless sudo. A key-only VPS needs a different access setup; use a test plan that offers password login.
- In the provider firewall, allow your Windows workstation to reach SSH (usually 22). Allow TCP 25 inbound and outbound, TCP 587 and 993 inbound, and TCP 80 and 443 inbound for HTTP certificate validation and HTTPS administration. Confirm outbound HTTPS can reach the package and image registries.
Connect from Windows
Extract the entire ZIP. Double-click MailServerSetup.exe. Select I already have a VPS, then enter the connection details from the provider. The Windows OpenSSH Client is required. If missing, search Windows Settings for Optional features and add OpenSSH Client.
At first connection, confirm the displayed IP and port and click Trust this server. Setup remembers the accepted server key for this Windows account. An unexpected key change stops the connection. Confirm any rebuild or address reassignment with your provider.
DNS tutorial
Open Domain & DNS in the installer. On Namecheap BasicDNS, use Domain List → Manage → Advanced DNS → Host Records → Add New Record for A and TXT records. Save each row with the green check mark. Enter your domain once. For example.com, Setup fills in mail.example.com and admin.example.com. You may edit either hostname. Replace example.com and the documentation IP 192.0.2.24 below with your own values.
Before installation
- Open the DNS dashboard for your domain's authoritative DNS provider. This may be your registrar or a service such as Cloudflare. The VPS itself does not need to supply nameservers.
- Open the DNS zone for the domain. Add the two A records below. For each A record, enter the VPS public IPv4 address in Value. Replace the example IP below with your own. Use the provider's default TTL. If its Host field appends the domain automatically, enter just
mail or admin. For Cloudflare select DNS only. The optional preview button in Setup can create missing A records with your explicit approval. - Check that both names resolve to the correct public IPv4 before requesting certificates. Publish AAAA only if IPv6 routes correctly to the corresponding services. A stale AAAA record can interfere with certificate issuance.
- In the VPS provider's IP or network settings, set reverse DNS (PTR) for the server IP to the full mail hostname. Make sure that hostname resolves back to the same IP.
Check and install
In Installation, click Check VPS. PASS means the check succeeded, FAIL needs attention, and UNKNOWN needs separate verification. The optional external SMTP test IP must belong to a server you have permission to test. Click Install and approve the installation. Save the report if a step fails. Retry with the same server and domain settings after correcting the cause.
Open the dashboard
When the setup reaches Your dashboard is ready, click Open dashboard in the Windows installer. A browser window opens. Use the tabs across the top of that page for the remaining steps. If the session expires, open a fresh dashboard from the installer.
In the web header choose Guide for these instructions. Bookmark explains how to save the page and offers a Windows shortcut. On your own private computer you can choose Remember this browser for 30 days. After expiry or sign-out, use Open an existing dashboard in the Windows app for a fresh session.
1. Verify that you own your domain
- In the browser, open Domains. Find your domain. Next to Ownership TXT, click Copy. Keep the dashboard open.
- Open your domain provider in a second browser tab. For Namecheap BasicDNS, choose Domain List → Manage → Advanced DNS → Host Records → Add New Record.
- Select TXT Record. In Host, type
_mail-verification. In Value, paste the code you just copied. Leave TTL on Automatic and save using the green check mark. If your provider asks for a full hostname, copy the complete name shown beside Ownership TXT.
- Return to Domains and click Verify TXT and activate. Continue when you see Verified and Enabled. If verification is pending, check the saved record, allow time for DNS caches to update, then click the button again.
2. Create the address that will receive your test reply
In the dashboard open Mailboxes → Create mailbox. Enter your full new address, a display name, and a mailbox password of 14–128 characters. New mailboxes start with 1024 MiB. Click Create mailbox and confirm your address appears in the list. To download your list later, choose Mailboxes → Export mailboxes → Download mailboxes.xlsx. Store this workbook privately. The workbook includes every page. A legacy account with only a password hash is marked Password unavailable. Set a new mailbox password once to include it in future exports. Expand a mailbox row to edit its settings. The trash button asks for confirmation before deleting access.
3. Set where incoming mail goes (MX)
This step routes incoming mail for every address on your domain. If you already receive mail elsewhere, prepare those addresses on the new server before switching. Save a copy of your previous MX settings.
- In the dashboard open Dns and find the MX row for your domain. Click Copy beside Value to copy the mail server hostname.
- In Namecheap choose Advanced DNS → Mail Settings → Custom MX. In other DNS panels choose Add record → MX.
- Set Host to
@, paste the hostname in Value / Mail Server, set Priority to 10, and leave TTL at its default. Save. If this VPS handles all incoming mail, check that the saved MX list contains only the intended mail server.
Namecheap's illustrated MX instructions
4. Authorize your VPS to send (SPF)
Open the DNS provider's Host Records. Look for a TXT record with Host @ and a Value beginning with v=spf1. Keep exactly one SPF record at this host. Other TXT records can stay.
- If you already have an SPF record: edit its Value. Add
ip4: followed immediately by your VPS public IPv4 address, after v=spf1 and before the existing rules. Keep a space between rules and preserve the entries for any other service you use. For example, an existing v=spf1 include:spf.efwd.registrar-servers.com ~all would become v=spf1 ip4:192.0.2.24 include:spf.efwd.registrar-servers.com ~all if the VPS address were 192.0.2.24. Replace the example IP with yours. A tilde is typed as ~, without a backslash. - If there is no SPF record and this VPS is your only sender: after the MX points to the VPS, add a TXT record, Host
@, Value v=spf1 mx -all. Save it. If you also send through a newsletter or another mail service, include its published SPF rule in the same record.
5. Publish your server's signing key (DKIM)
- Return to the dashboard Dns tab. Find the TXT row whose hostname contains
._domainkey. It appears after ownership verification. If the key is unavailable, reload the page after verification succeeds. - At your DNS provider, add or edit the TXT record for that exact Host. The initial short Host is usually
mail._domainkey. Use the full name from the dashboard only when the provider requests it. - In the dashboard click Copy beside the DKIM Value. If the button says Press Ctrl+C, press those keys. Paste the entire clipboard into the DNS provider's Value box. The Observed line shows what is already published.
- Before saving: look for
p= followed by a long string of letters, numbers and possibly symbols. If you see three dots or an empty key, return to the dashboard and copy again. Each server has its own key; there is no sample DKIM value to type from this guide. - Save, then refresh Dns until the DKIM record shows Matched.
6. Set the domain's authentication policy (DMARC)
Look for an existing TXT record with Host _dmarc. If you already have one, keep the current policy and review it with whoever manages your mail. For a new domain, create TXT, Host _dmarc, Value v=DMARC1; p=none, default TTL, then save. This initial policy lets you check alignment before choosing quarantine or reject. For aggregate reports add a rua destination you control.
7. Check what the internet sees
Refresh the dashboard Dns tab. Value is the suggested setting; Observed is the public result seen by the server. A recent edit can take time to appear. For a custom SPF rule, Review can simply mean it differs from the suggested text. Check that Observed contains one SPF policy authorizing your VPS. Check MX points to your mail hostname and DKIM shows Matched.
8. Connect a mail app and test both directions
Choose manual account setup in your mail app. For both servers enter the mail server hostname you set in the installer. Use your full mailbox address as the username and the mailbox password you created in step 2.
| Setting | Port | Encryption |
|---|
| Incoming (IMAP) | 993 | SSL/TLS |
| Outgoing (SMTP), authentication enabled | 587 | STARTTLS before login |
- From the new mailbox send a fresh message with a unique subject to an external address you control. Check its inbox and spam folder.
- In Gmail, open the message and choose More → Show original. Look for SPF, DKIM and DMARC PASS. For DMARC, the visible From domain must align with the domain authenticated by SPF or DKIM.
- Reply from the external mailbox and confirm the reply appears in your new IMAP inbox. This also tests the public MX routing.
Google's email sender guidelines
Snapshots and recovery
Use your provider dashboard to create and name a snapshot before updates. Confirm it covers the system disk and every volume that holds mail, queue state, keys and database files. Take a consistent snapshot following the provider's instructions; this may require shutting down the VPS. A restore returns the captured disks to that point in time, so messages received later may be lost. Restore first to an isolated test VPS and verify a mailbox before depending on the snapshot.
Troubleshooting
SSH login failed. Check the username, port and password. Confirm that the provider supports password SSH and that the account has the required privileges.
Certificate request failed. Check both A records, AAAA records and inbound TCP 80. A proxy or stale record may send validation to a different machine.
Mailbox creation unavailable. Verify the ownership TXT and ensure the domain is active. The public dashboard landing page directs you to the installer. Use Open an existing dashboard to open an authenticated session.
Sending works locally only. Verify outbound TCP 25 with the provider and check the delivery queue. Keep the test domain separate until a real external send and reply succeed.
The mail app says Sent, but the message is missing. In the dashboard, check Queue for a delay reason. If it is empty, open Operations and filter by the recipient. A bounced message has stopped retrying. Open the delivery failure notice in the sending mailbox and read the recipient server's explanation. For Gmail error 550 5.7.26 with SPF and DKIM failures, revisit steps 4 and 5 and send a new message once the corrected records are visible.