Dead Letter

Share
Dead Letter
Photo by Sander Sammy / Unsplash
Ghost · Self-Hosted · Mailgun

Six months of broken newsletters, four unsent posts, and an IP allowlist nobody remembered setting.

161
Days Offline
76
Emails Delivered
1 IP
Root Cause

The newsletters are sending again. Four posts that were written, published, and silently swallowed by a 401 error are now sitting in inboxes where they should have arrived months ago. The whole thing came down to a single IP address in an allowlist I didn't remember setting, on an account I'd already spent hours remediating.

I should probably start at the beginning.


01 The Compromise

Back in June, Mailgun's abuse system flagged my account. Someone had gotten hold of the API credentials for mg.mtnsolutions.pro and fired off six batches of spam—subject line "Test," 22 recipients each, all rejected before delivery. Mailgun shut the account down. I rotated every credential I could find, dug through the Ghost VM looking for signs of intrusion, found nothing, filed the paperwork, and eventually got the account re-enabled.

The newsletters stopped on May 24th. The last one my subscribers received was "Full Neighborship, Nothing Learned." Everything after that—Ghost accepted the publish, queued the email, and then watched Mailgun reject it. For six months.

02 The Wrong Diagnosis

When I came back to fix the email sending in December, Ghost was throwing 401 Forbidden on every Mailgun API call. Email analytics was 232,000 minutes behind—about 161 days. So I did what anyone would do: rotated the API keys. Created new ones. Tested them with curl. Invalid private key.

Created more keys. Tested those. Same error. Tried domain-level sending keys. Account-level keys. Keys I created on the spot and tested within seconds of their creation. All invalid. I opened a ticket with Mailgun and waited.

The maddening thing was that SMTP routing still worked for mg.cerasani.net—another domain on the same account. Receiving worked. Forwarding worked. Just the API refused to authenticate anything, on any domain, with any key.

03 One IP Address

Fred from Mailgun support found it on December 3rd. Buried in the account settings was an IP allowlist. One entry: 73.217.26.253. An old Comcast IP from Colorado Springs—a DHCP lease I hadn't held in months.

The allowlist was blocking all API and SMTP traffic from any IP that wasn't on the list. My current dynamic IP was different. The API keys were valid the entire time. Mailgun wasn't even getting to the point of checking the key—it was rejecting the connection at the network level before authentication could happen.

I removed the entry from the dashboard. Tested with curl. The domain info came back clean. No "Invalid private key," just JSON with sending stats and DNS records like nothing had ever been wrong.

Six months of broken newsletters. Because of one stale IP in a settings page I'd probably configured during initial setup and completely forgotten about.
04 The @ That Wasn't There

With the API working, I expected Ghost to pick up where it left off. It did not. The SMTP transactional emails—the ones that send staff login verification codes—were still failing silently.

Ghost's config file had a from field set to noreply.mtnsolutions.pro. Not [email protected]. Just the domain, no @, no user part. The entire concept of an email address, missing. This had probably been wrong for a while—maybe since the original setup—masked by the fact that Mailgun was apparently lenient about malformed sender addresses until it wasn't.

Fixed the config. Rotated the SMTP credentials. Restarted Ghost. Verification codes started arriving. Logged into Ghost Admin for the first time in months.

05 Talking to Myself

Four newsletter posts were stuck in submitting status: Zero Touch, Tunnel Vision, Deep Reset, Owner Null. Ghost had tried to send each one, hit the 401 wall, and frozen. Twenty-two recipients queued per post, zero delivered, zero failed. Just stuck.

Getting to the MySQL database to fix them was its own project. The Ghost VM runs Docker, but my user account wasn't in the docker group and needed a sudo password for a non-interactive session. So I tried the elegant route: Proxmox serial console. Wrote Python scripts that opened PTYs, forked socat processes, used select() for non-blocking reads, and carefully parsed output from the VM's serial socket.

The output I was carefully parsing turned out to be my own input echoed back by the PTY. The serial console was sitting at a login prompt the entire time. I spent a genuinely humbling stretch of troubleshooting having a conversation with myself through increasingly sophisticated IPC machinery.

Multiple Python scripts, two layers of process forking, and a UNIX domain socket—all to echo my own commands back to me while a login prompt waited patiently for a username.

The eventual fix was much less cinematic. SSH in directly, run two commands to set up docker access and passwordless sudo, and query the database like a normal person.

06 Unsticking the Queue

The email batches had the same broken from address cached from the original failed send attempts—"noreply.mtnsolutions.pro" <>, the missing-@ variant, baked right into the error data. Even with the API working, resending with that sender field would have failed all over again.

Corrected the from address in the emails table to match the working pattern from older successful sends. Reset the status to failed so Ghost Admin's retry button would reappear. Clicked retry on each post.

All four went through. Nineteen delivered, three failed per post—the exact same ratio as every successful newsletter before the compromise. The three failures are probably abandoned inboxes. They failed before June too.

07 What Was Actually Broken

The thing that gets me about this whole saga is how many layers of reasonable-looking failure were stacked on top of one actual problem. The API keys looked invalid. The SMTP looked misconfigured. The email batches looked corrupted. Ghost itself looked broken. And underneath all of it was a single IP address in an allowlist field that nobody—not me, not two rounds of Mailgun support—thought to check for five months.

Every error message was technically accurate and completely misleading. "Invalid private key" is what Mailgun returns when your IP isn't allowed—because from its perspective, the request never got far enough to be invalid. The key was fine. The door was locked from the outside.

I keep thinking about how many problems work this way. The symptom describes itself with total confidence, and you spend your time fixing exactly what it told you was wrong, never questioning whether the error message is reporting the actual failure or just the first thing it noticed on the way down.

Anyway. The newsletters are sending. Seventy-six emails delivered across four posts, after 161 days of silence. All because I removed one IP address from one settings page.

Which is a sentence that probably says a lot about the last six months.