5

Like many web apps, we use Postmark to send all notifications for server side events. Many of our events are grouped and related by something simple and logical (think multiple replies to the same issue, like in GitHub).

Right now, every email sent for these related events is it's own email thread. My question is: how do I send these emails so that related ones get pushed into the same thread?

I'm not sure if this is something at the Postmark level (like include a previous message ID) or if this is something I do with SMTP (like I should format my subject better and inline previous responses), so that's why I'm seeking guidance. Also, every Google search about: "Postmark email threads" returns concerns over the thread safety of the Ruby Gem.

For more information, the app is written in PHP and right now we are znarkus/postmark-php for sending emails and jjaffeux/postmark-inbound-php for parsing inbound ones. However, I am more than willing to add any extra packages if they help me in my quest.

Thanks in advance!

hjc1710
  • 576
  • 4
  • 17

1 Answers1

6

You can add a few SMTP headers with the original Message-ID that most clients use to link together replies. If the original email had a Message-ID header of <123@mail.example.com> the new email you send out should keep the subject line the same and add headers of:

  • In-Reply-To: <123@mail.example.com>
  • References: <123@mail.example.com>

And that should inform clients that the two emails should be threaded.

Edit:

The value for these headers should be the SMTP Message-ID header, which is slightly confusing because it is a separate concept from the Postmark MessageID value, which is just a UUID for the email.

The SMTP Message-ID header is always in the form an email address, because that's how it's supposed to be formed, but doesn't have to be related to the from address.

Nick Canzoneri
  • 3,774
  • 1
  • 23
  • 17
  • 1
    Awesome! This seems like it would give me what I'd want, but I can't really test it and prove it, just yet, so I'm going to hold off on accepting this as the answer. You say I need to keep the subject the same, do email clients add: "Re:" automatically to threaded replies? Or do I have to? And thanks a lot! – hjc1710 Dec 15 '15 at 00:32
  • If you're sending the reply, then you would need to add the "Re:" if you want it to appear. Testing with Gmail, it still threaded the convo as long as it was the same subject. Looking forward to see how it goes! – Nick Canzoneri Dec 15 '15 at 14:56
  • So, looks like the `Message-ID` is a UUID, which seems fine, but in your example for `References` you alter the domain. How do I apply this to Postmark? Or should I not be using the Message-ID UUID and, instead, be using the email address? Or the `123` in your examples the `Message-ID`, meaning the format is: `$UUID@smtp.postmarkapp.com` for `In-Reply-To` and `$UUID@smtp.postmarkapp` for `References`? Thanks so much for your help! – hjc1710 Dec 17 '15 at 17:08
  • Sorry the change to the `References` header was a typo. I edited my answer to hopefully explain that it's the Message-ID header value that you need to include in the reply headers. – Nick Canzoneri Dec 21 '15 at 15:35