Product

Tracking replies in Mailgun (or any other email service)

We’ve recently been inundated with questions about how to track which email a recipient has replied to. There are many use cases for needing to do this. You may want to thread a conversation in your App or you may want to measure engagement.

PUBLISHED ON

PUBLISHED ON

We’ve recently been inundated with questions about how to track which email a recipient has replied to. There are many use cases for needing to do this. You may want to thread a conversation in your App or you may want to measure engagement. The problem with relying on Mailgun Tags or Campaign-IDs is that these are not standard MIME headers so the receiving email service provider (ESP) may strip them out.

The proper way to do this is to use the Message-ID header because when a recipient replies to an email the Message-ID of the original email is included in the In-Reply-To header of the reply.

Let’s walk through an example.

When you send an email using Mailgun, Mailgun automatically creates a Message-ID and includes it in the response (you could also set your own custom Message-ID).

So if I send a message using the messages API:

curl -s -k --user api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0 https://api.mailgun.net/v2/samples.mailgun.org/messages -F from='Excited User <me@samples.mailgun.org>' -F to='test <test@mailgunhq.com>' -F subject='Hello' -F text='Testing some Mailgun awesomness!'

Mailgun replies with:

"message": "Queued. Thank you.", "id": "<20120502235917.29259.30669@samples.mailgun.org>"

You can see it in a screen shot of my terminal:

Now when I open that email in an email client and look at the email source headers, you can see that Message ID:

Ok, now let’s see what happens when I reply to that email. I created a Route in Mailgun that posts my reply to a URL at Postbin. Of course, Mailgun dutifully posts all of the headers. As you can see below, the In-Reply-To header has the same Message-ID which you then can use to identify which specific email was replied to:

So that’s it, an easy way to track who’s replying to what.

Happy emailing!

Mailgunners

Sign Up

It's easy to get started. And it's free.

See what you can accomplish with the world’s best email delivery platform.

Related readings

Agape charity finds easy way to forward email for volunteers worldwide

I volunteer part time at the Agape Community Care Association (www.agape.org), an NGO that helps orphans and other...

Read more

How Kanban2go fulfills Zawinski’s Law

I don’t know if that is true, but kanban2go took a step in that direction recently with the...

Read more

Python tutorial: How ImgPage lets you upload 25 MB photos to S3 and Cloud files with just an email

This post is written by Paul Finn. Paul is a Portsmouth, NH-based Python developer, business owner (http://route3software.com/) and...

Read more

Popular posts

Two men talking about email authentication

Build Laravel 10 email authentication with Mailgun and Digital Ocean

When it was first released, Laravel version 5.7 added a new capability to verify user’s emails. If you’ve ever run php artisan make:auth within a Laravel app you’ll know the...

Read more

Gods with gears in city street

Sending email using the Mailgun PHP API

It’s been a while since the Mailgun PHP SDK came around, and we’ve seen lots of changes: new functionalities, new integrations built on top, new API endpoints…yet the core of PHP...

Read more

God with mask on chair

Here’s everything you need to know about DNS blocklists

The word “blocklist” can almost seem like something out of a movie – a little dramatic, silly, and a little unreal. Unfortunately, in the real world, blocklists are definitely something you...

Read more

See what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending
CTA icon