Getting the Newsletter Working with Mailgun: A Journey Through Email Hell

Getting the Newsletter Working with Mailgun: A Journey Through Email Hell

There comes a point in every website owner's life where they think:

“You know what this site needs? A newsletter.”

Seems simple enough.

People enter their email. The website sends them an email. Everyone lives happily ever after.

HAHAHAHA.

I decided to get the newsletter working, because apparently running a website, maintaining servers, fighting DNS, and debugging random PHP errors wasn't enough suffering for one lifetime.

Enter Mailgun.

Step 1: Sign Up for Mailgun

Easy.

Create account.

Verify account.

Configure domain.

Simple.

I was feeling optimistic.

This was my first mistake.

Step 2: DNS

Mailgun looked at my domain and said:

“That's cute. Now prove you own it.”

So began the ancient ritual of adding DNS records.

SPF.

DKIM.

CNAME.

TXT.

More TXT.

At this point my DNS zone looked like someone had spilled alphabet soup into it.

I added everything Mailgun requested and waited.

And waited.

And refreshed.

Eventually Mailgun decided that, yes, I apparently owned my own domain.

Victory.

For approximately 11 seconds.

Step 3: Actually Sending Email

Now came the exciting part.

The newsletter system was configured.

Mailgun was configured.

The domain was verified.

Everything was green.

I clicked Send Test.

Nothing.

Absolutely nothing.

The email had entered the digital void.

I checked spam.

Nothing.

Checked Mailgun.

Nothing useful.

Checked the website.

Nothing.

Checked the server.

Also nothing.

At this point I was basically yelling at DNS.

Step 4: Discovering That Email Is Basically Black Magic

Eventually I found the problem.

The newsletter system was doing exactly what I told it to do.

Unfortunately, what I told it to do was wrong.

The Mailgun credentials were correct.

The domain was correct.

The API endpoint was correct.

But one tiny configuration detail was wrong.

Because of course it was.

It wasn't some catastrophic server failure.

It wasn't a firewall.

It wasn't Mailgun being broken.

It was one stupid setting.

The most dangerous kind of setting.

The kind that looks completely reasonable.

Step 5: The First Successful Email

I hit send again.

I watched the Mailgun logs.

200 OK.

Holy shit.

It worked.

I checked my inbox.

Nothing.

I waited.

Still nothing.

Then...

DING.

Newsletter.

Delivered.

Beautiful.

Majestic.

A tiny HTML email had successfully traveled across the internet and arrived in my inbox.

I had never been so proud of a message containing three sentences and a link.

The Final Boss: Deliverability

Of course, getting an email delivered to me doesn't mean the job is finished.

Now comes the wonderful world of email reputation, SPF, DKIM, DMARC, spam filters, bounce handling, unsubscribe links, tracking, and making sure Gmail doesn't look at my newsletter and immediately throw it into the electronic dumpster.

Because apparently sending email is no longer:

“Send this message to Bob.”

It's now:

“Please submit this message to the International Council of Extremely Suspicious Email Machines and hope they find your vibes acceptable.”

So that's the next adventure.

Was Mailgun Worth It?

Honestly?

Yeah.

Once everything is configured, Mailgun makes the actual sending part pretty painless.

The difficult part was getting everything configured correctly in the first place.

DNS verification was annoying.

Troubleshooting was annoying.

Waiting for emails was annoying.

Wondering if I had accidentally configured my domain to send email directly into the sun was annoying.

But now the newsletter actually works.

People can subscribe.

Emails can be sent.

And, most importantly, I no longer have to manually test it every five minutes by subscribing with increasingly ridiculous email addresses.

Final Status

Newsletter: ✅
Mailgun: ✅
DNS: ✅
DKIM: ✅
SPF: ✅
Emails arriving: ✅
My sanity: ❌

Would I do it again?

Probably.

Would I recommend doing it?

Absolutely.

Would I recommend doing it at 2 AM while staring at DNS records?

Absolutely fucking not.

Email is easy.

They said.

😐.

P.S sorry if there was a Spam of Newsletters :P

Subscribe to Circle Jerks of America

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe