Mailfornet

How to set up your own email server or email domain

People who ask how to set up your own email server usually want one of two things. Some want an address on their own domain, like you@yourname.com, and don't care where the mail is stored. Others want to run the whole system themselves, on a machine they control. The first takes twenty minutes. The second is a weekend project followed by ongoing maintenance. This guide covers both, so you can choose before you spend money.

Short answer: owning the domain gives you most of the benefit. You can move between providers whenever you like and keep the same address. Running the server yourself adds control and privacy, and a real risk that your mail goes to spam.

Three ways to have your own email system

RouteWhat you getCostDifficulty
1. Forwarding on your domainyou@yourdomain.com arrives in your existing Gmail or Outlook inboxFree, plus the domainEasy
2. Hosted mailbox on your domainA full mailbox, sending and receiving, run by a mail companyA few dollars per user per monthEasy
3. Self-hosted mail serverEverything on your own serverA small monthly server fee, and your timeHard

Whichever you choose, the first step is the same: register a domain. A .com costs roughly $10 to $15 a year at any registrar.

Route 1: free forwarding on your own domain

This is the quickest way to get a professional-looking address. A forwarding service receives mail for your domain and passes it on to an inbox you already have.

  1. Add your domain to a forwarding service. Cloudflare Email Routing is free if your domain's DNS is on Cloudflare; ImprovMX and similar services work with any registrar.
  2. Create a rule: hello@yourdomain.com forwards to you@gmail.com.
  3. Confirm the destination address from the email the service sends you.
  4. Let the service add its MX and SPF records, or copy them into your DNS.

The limit is sending. Forwarding only handles incoming mail, so replies go out from your Gmail address unless you also connect an outgoing (SMTP) service. For a personal site or a side project that mostly receives mail, that is often enough.

Route 2: a hosted mailbox on your domain

This is what most small businesses use. A provider runs the servers; you point your domain at them. Well-known choices are Google Workspace, Microsoft 365, Zoho Mail, Fastmail and Proton Mail, and Apple's iCloud+ lets you attach a custom domain to iCloud Mail.

  1. Sign up and enter your domain.
  2. Prove you own it by adding the TXT record the provider gives you.
  3. Create your mailboxes: you@, billing@, support@.
  4. Replace your domain's MX records with the provider's.
  5. Add the SPF record and switch on DKIM in the provider's admin panel.
  6. Add a DMARC record.

DNS changes usually take effect within an hour. Your mail then works in the normal apps on your phone and computer, and the provider handles spam filtering, backups and deliverability.

Route 3: run your own mail server

This is true self-hosted email. You rent or own a server and run the software that receives, stores and sends your mail.

What you need

  • A VPS with a static IP address and at least 2 GB of memory. A home internet connection rarely works, because most residential providers block port 25 and their IP ranges are on blocklists.
  • Port 25 open for outgoing mail. Several cloud companies block it by default on new accounts; ask before you pay.
  • Control of reverse DNS (the PTR record) for that IP address.
  • A clean IP. Check it against blocklists such as Spamhaus on day one. A previous customer may have used it for spam.

The software

You can assemble the classic stack by hand: Postfix to send and receive, Dovecot to store mail and serve it over IMAP, Rspamd for spam filtering and DKIM signing, and a webmail front end such as Roundcube. Most people are better served by a bundle that installs and configures all of that together:

  • Mail-in-a-Box: the simplest; turns a fresh Ubuntu server into a mail server with one script.
  • Mailcow: Docker-based, with a good admin interface.
  • Stalwart: a newer all-in-one server written in Rust.
  • iRedMail and Modoboa: long-established installers for the classic stack.

The setup in outline

  1. Give the server a hostname such as mail.yourdomain.com and an A record pointing to its IP.
  2. Set the PTR record so the IP resolves back to that same hostname.
  3. Run the installer and create your first mailbox.
  4. Add the DNS records in the next section.
  5. Get a TLS certificate (the bundles do this with Let's Encrypt).
  6. Send a test to a Gmail address, open "Show original" and confirm SPF, DKIM and DMARC all say PASS.

The DNS records every mail domain needs

RecordWhat it doesExample
MXTells the world which server receives your mail10 mail.yourdomain.com
APoints the mail hostname to an IP addressmail → 203.0.113.10
PTRReverse lookup: IP back to hostnameSet at your server host
SPF (TXT)Lists who may send for your domainv=spf1 mx -all
DKIM (TXT)Publishes the key that verifies your signatureGenerated by your server
DMARC (TXT)Says what to do when SPF and DKIM failv=DMARC1; p=quarantine

These apply to all three routes; with a hosted provider you simply copy their values. Each one is explained in SPF, DKIM and DMARC explained simply, and the journey a message takes between servers is in how email actually works.

Why self-hosted email ends up in spam

Receiving mail on your own server is straightforward. Sending is the hard part. Gmail, Outlook and Yahoo judge mail by the reputation of the sending IP and domain, and a new server has none. Even with perfect records, your first messages may be filtered or rejected, and Microsoft in particular is strict with small senders.

The common workaround is a hybrid: receive on your own server, and send through an SMTP relay such as Amazon SES, Mailgun or Postmark, whose IP addresses already have a reputation. You keep your data and gain reliable delivery. If messages still go missing, work through why emails go to spam and read the bounce codes that come back.

Should you run your own email server?

  • Yes, if you want to learn how mail works, need full control of where data lives, or host many mailboxes and can maintain a server.
  • No, if a missed email would cost you a customer or a job offer. A server that is down, full or blocklisted fails silently, and you are the support team. Security updates, backups and monitoring are permanent chores.

For most people the best balance is route 2 on a domain they own. You can change provider in an afternoon by editing the MX records, and your address never changes.

Common questions

Can I create my own email domain for free?

The domain name itself costs money. Forwarding on it can be free, and some providers have free or very cheap mailbox plans for one domain.

Can I run an email server at home or on a Raspberry Pi?

For receiving and for learning, yes. For sending, a home connection is usually blocked on port 25 and distrusted by other servers, so you would need an SMTP relay.

Is a self-hosted email server more private?

Your stored mail is under your control, which is a real gain. But every conversation has another side: if your contacts use Gmail or Outlook, those companies still hold a copy.

Do I need my own server just to receive sign-up emails?

No. For throwaway sign-ups a temporary email address does the job in seconds, and developers who need inboxes for automated tests can create them through the Mailfornet API without running anything.

Get a free temporary email SPF, DKIM and DMARC explained