Wang Wenhao's Blog Notes on data, tooling and solo development — the personal blog of Wang Wenhao.
← Back to blog

Migrating My Domain Email: From iCloud + Tencent Exmail to Purelymail

11 min read AIGC
Email DNS Sysadmin

I own two domains: abetterplace2.live was on iCloud custom domains, and retter.wang was on Tencent Exmail. Both worked, but neither felt right — one locked me into Apple's ecosystem, the other into WeCom. What I wanted was the plainest thing possible: my own domain, any mail client, standard IMAP.

So I did the migration. Here's the whole process, including the pitfalls I hit and one inexcusable operational accident.

1. The conclusion first

Item Result
Final choice Purelymail, $10/year
Time spent About 40 minutes (excluding the time spent deciding)
Record changes 6 added, 3 removed per domain, everything else kept
Pitfalls 5 technical + 1 production incident
Status Both domains fully served by Purelymail, IMAP/SMTP working

2. The path I ruled out: self-hosting

I had an Alibaba Cloud ECS (2 vCPU / 2 GB, running nginx and frp) and a UGREEN NAS (N100, 7.5 GB RAM, 1.3 TB storage). On paper the NAS is an ideal host for a self-built mail server.

After some research I found three hard constraints, any one of which kills the idea.

Constraint 1: Alibaba Cloud bans "self-hosted MTA direct delivery", not "port 25"

This is the most commonly misunderstood part. Many people assume that once port 25 is unblocked, they can run their own mail server. In reality, the core clause of Alibaba Cloud's port-25 unblocking agreement is:

The unblocked IP may only connect to third-party SMTP servers to send mail. If the IP is found sending mail directly via SMTP, Alibaba Cloud reserves the right to permanently block TCP port 25 with no further unblocking service.

In other words, unblocking buys you permission to connect to someone else, not permission to become a post office yourself. Running Postfix on Alibaba Cloud and delivering straight to a recipient's port 25 violates the agreement and gets you cut off for good.

Outbound mail must go through a smarthost relay. It is not optional.

Constraint 2: A new IP's deliverability cannot be fixed by configuration

SPF, DKIM and DMARC are an entry ticket, not a pass. Whether a recipient accepts your mail depends on the historical reputation of the IP and the domain.

The reality in 2026: a brand-new IP is presumed spam by default. Microsoft is especially difficult — it returns 250 OK and then silently drops your message into the junk folder, so you don't even get an error. Perfect SPF doesn't help, because the problem isn't authentication, it's reputation.

That's exactly what relay providers sell: IP pool reputation they spent years building.

Constraint 3: 2 GB of RAM won't run mailcow

Option Memory footprint Feasible
mailcow 6 GB+ per official docs ❌
docker-mailserver 800 MB – 1.2 GB ⚠️ Marginal
Stalwart (single Rust binary) 150–250 MB ✅
Postfix + Dovecot + Rspamd 400–600 MB ✅

And my ECS was already running nginx (8 sites) and frps (12 tunnels). Anything I added would have to be the lightest possible stack, competing for resources with production workloads.

Side note: the NAS isn't a good fit either

The NAS has plenty of RAM and storage, but there's a fatal problem — UGREEN's UGOS ships an earlyoom (userspace OOM daemon) that has a history of killing containers. My earlier diagnostics showed that none of the 13 containers had a memory limit, and dockerd once leaked to 3.66 GB, filled swap, and triggered earlyoom to SIGKILL everything in sight.

Email is a 7×24 service that must not be interrupted. Colocating it with experimental containers that get poked at constantly is an unacceptable risk.

Conclusion on self-hosting: technically possible, but the price is "you must relay + you own the ops + you live with uncertain deliverability". If that's the deal, why not just use someone else's professional service?

3. Choosing: why Purelymail

The requirements were simple: two domains, unlimited aliases, standard IMAP, cheap.

I compared a few:

Service Price Domains Aliases IMAP Notes
Purelymail ~$10/year Unlimited Unlimited ✅ Usage-based billing, unlimited users
Migadu From $19/year Unlimited Unlimited ✅ Micro tier caps you at 20 outbound/day
MXroute From $59/year Unlimited Unlimited ✅ Priced by storage, 400/hour
Fastmail From $60/year Yes Hundreds ✅ Best experience, also the priciest
Zoho Mail $1/user/month 1 + aliases Tiered ⚠️ Free plan has no IMAP

I went with Purelymail: $10 a year, unlimited domains, unlimited mailboxes, Sieve support, catch-all support. For a single user, nothing else comes close on value.

Its known downsides are listed by the vendor on their own homepage: a few obscure mail servers occasionally reject its mail; no 24×7 support; the UI isn't great; marketing blasts and domain warming are prohibited.

4. DNS: six records

Onboarding a domain to Purelymail needs the following records. Note the MX priority is 50, not the usual 10 — that's an explicit requirement.

Type Host Value Purpose
TXT @ purelymail_ownership_proof=<token> Domain ownership proof, required
MX @ mailserver.purelymail.com (priority 50) Inbound mail
TXT @ v=spf1 include:_spf.purelymail.com ~all Outbound authorization
CNAME purelymail1._domainkey key1.dkimroot.purelymail.com DKIM key 1
CNAME purelymail2._domainkey key2.dkimroot.purelymail.com DKIM key 2
CNAME purelymail3._domainkey key3.dkimroot.purelymail.com DKIM key 3
CNAME _dmarc dmarcroot.purelymail.com DMARC policy
CNAME autoconfig autoconfig.purelymail.com Client autodiscovery (optional)

The ownership proof token is account-level: every domain shares the same one, so you only fetch it once.

One counterintuitive detail when adding a domain: the ownership TXT alone is enough to add it. MX/SPF/DKIM all get filled in afterwards. So the flow is "prove ownership, then add capabilities" — you don't have to do it all at once.

5. Five pitfalls

Pitfall 1: MX priority 10 means you get no mail

Almost every mail provider uses 10 or 5 as the MX priority. Purelymail wants 50. Copy the habit from another provider and inbound mail simply fails.

Pitfall 2: the _domainkey part goes in the host field

The correct form:

Type:  CNAME
Host:  purelymail1._domainkey
Value: key1.dkimroot.purelymail.com

Getting it backwards is the hardest kind of bug to find — DNS propagation is slow, the feedback loop is long. You wait an hour to discover the typo, then wait another hour to verify.

Pitfall 3: _dmarc can't have both TXT and CNAME

If your domain already has a _dmarc TXT record (say v=DMARC1; p=none), you cannot also add a _dmarc CNAME — the same hostname cannot hold both a CNAME and a TXT record.

That's exactly the situation with my retter.wang. The fix: keep the existing TXT, skip the CNAME. Purelymail's dashboard will warn about it; that's expected and doesn't affect sending or receiving.

Pitfall 4: skip Save and outbound mail returns 503

Once the DNS records are in and Purelymail shows all four checks green, you must click Save once.

The docs call this out specifically: only clicking Save pushes the verification state and DKIM signing config to the mail cluster. Skip it and sending fails with:

503 Cannot send mail: check SPF or DKIM records

It looks like a DNS problem. It's actually a button you didn't click.

Pitfall 5: the wrong catch-all option empties your own inbox

Purelymail's routing rules offer four matching modes, two of which look like "receive everything":

Option Consequence
any address ❌ Even mail to me@ gets redirected; your main inbox goes empty
any address except valid user address ✅ Main inbox works, other aliases land in it

Straight from the docs:

If you have a User at me@domain.com but a routing rule for *@domain.com, all mail will follow the rule. The me@domain.com inbox will stay empty.

Pick wrong and your own primary mailbox receives nothing. You must choose "except valid user address".

6. Post-mortem: I deleted my own MX records

This part is a little embarrassing to write, but it's the most valuable lesson from the whole migration.

What happened

I was adding records one by one in the Alibaba Cloud console. To avoid repeated clicking I used coordinate-based clicking (automation) rather than manual clicks.

The trouble came when dismissing the tooltip overlay on the "host record" input — I sent two clicks at blank space around x=1600, y=640. That position actually landed in the row action area on the right side of the record list, hitting Delete. The series of "OK" clicks I made to submit the form then confirmed the delete dialog.

The MX and SPF records for both domains were gone, just like that.

Why I didn't notice

Because recursive DNS caches.

Right after deleting, I queried DNS and 223.5.5.5 still returned mx01.mail.icloud.com — the cached old value, with 376 seconds of TTL left. Everything looked fine.

What actually exposed the problem was pulling the full record list through the API: 13 records, and neither MX nor SPF among them.

How I found it

The key move: bypass recursive DNS and ask the authoritative NS directly.

nslookup -type=MX retter.wang dns27.hichina.com
nslookup -type=TXT retter.wang dns27.hichina.com

The authoritative server returned SOA instead of MX — proof the records really were gone. The cache had lied to me for ten minutes.

Impact and recovery

  • Outage window: roughly 15–20 minutes
  • Potential fallout: mail sent during that window may have bounced with a permanent "no MX record" error at the sender
  • Recovery: re-added the 6 records via API (4 MX + 2 SPF), verified against the authoritative NS

Three lessons

  1. Never use coordinate clicking for DNS changes in production. Always go through the API — auditable, reversible, and it can't miss.
  2. Recursive DNS lies. To verify a DNS change you must query the authoritative NS: nslookup -type=MX <domain> <authoritative-ns>.
  3. Snapshot before every change. I later wrote switch_mx.py snapshot, which dumps all records to JSON so rollback is a single command.

7. The correct order to switch

After the records are in, there's still the real "flip the switch" step: changing MX. The order matters:

1. Add ownership TXT             → prove domain ownership
2. Create the User in Purelymail → must exist first
3. Add DKIM ×3 + DMARC           → doesn't affect current mail flow
4. [SWITCH] remove old MX + add new MX + swap SPF
5. Click Check DNS → Save in Purelymail
6. Configure the client + send/receive tests
7. Migrate historical mail
8. After 7 stable days, clean up the old provider's leftovers

Step 2 must come before step 4. Once MX points at Purelymail, non-existent recipients get a straight 550 rejection. Create the address first, then switch MX.

Another detail: SPF allows only one record. Removing old MX, adding new MX, removing old SPF and adding new SPF must happen as one continuous sequence, not split into two sittings — otherwise, during the switch window the old provider is still sending but no longer authorized.

A trick to verify before switching

How do you confirm Purelymail has taken over your domain? Probe it like this:

# Connect to mailserver.purelymail.com:25 and RCPT TO any address
RCPT TO:<nonexistent@yourdomain.com>
  • 451 4.7.1 Try again later (greylist) → the domain is already onboarded (just greylisting delay)
  • 550 relay denied → the domain isn't added yet

Greylisting is a good sign: it means Purelymail recognizes your domain and is merely filtering spam.

8. Aliases: an easy-to-miss pitfall

After the switch I noticed a problem: I'd only created me@domain.com. What about career@domain.com and info@domain.com?

They receive nothing. They get rejected.

Purelymail only delivers to Users you created or addresses matching a routing rule. Everything else gets a 550.

The fix is a catch-all route (using that "any address except valid user address" option from earlier). Once configured, any alias reaches you, all landing in the primary inbox.

Best to set this up before switching MX, otherwise mail to aliases bounces during the switch window.

9. Cost and loose ends

Item Value
Purelymail $10/year
Records per domain 6 added, 3 removed
Client settings IMAP imap.purelymail.com:993, SMTP smtp.purelymail.com:465
Sending limits 3000/day, 300 per batch
Server location AWS us-east-1

Two things I left undone:

  • Historical mail migration: old mail on iCloud and Tencent is still there; Purelymail's built-in mail porting tool can pull it over.
  • Cleaning up the old provider: sig1._domainkey (iCloud DKIM), the apple-domain verification TXT, and Tencent's qqmail CNAME are all leftovers — delete them after a stable week.

The order can't be reversed: migrate historical mail first, then unbind the old provider. Once unbound, access to the old mailbox may be affected.

10. Summary

If I could do it again:

  1. Confirm current records against the authoritative NS and take a snapshot
  2. Make every change through the API, never by clicking in a console
  3. Follow "prove ownership → create address → add authentication → switch MX"
  4. Configure catch-all before switching
  5. Verify with the authoritative NS after every change; don't trust recursive caches

The conclusion on self-hosted email: you can self-host receiving, but sending must go through a relay. And if sending will depend on someone else's IP reputation anyway, you might as well hand both directions to a professional service and spend your own time writing code.

The time saved is enough to write several more posts.