Message-ID header doesn't work match expected Message-ID in In-Reply-To header

Hi! I’ve set up Email Routing on my domain and connected it to an Email Worker á la https://developers.cloudflare.com/email-routing/email-workers/reply-email-workers/

Receiving and processing emails work, but when I attempt to reply I get the following error:

{
      "name": "Error",
      "message": "In-Reply-To does not match original Message-ID",
      "timestamp": 1698525981331
}

It seems that when In-Reply-To is being compared it is also including the stripped spacing-characters in front of the Message-ID. When I tried including the spacing characters from some of the emails in the In-Reply-To header then I was able to reply correctly.

For example:

When I inspect my email sent from my GMAIL account the header is Message-ID: <MESSAGE_ID> and by adding the space before the <MESSAGE_ID> I was able to respond to my gmail.

msg.setHeader("In-Reply-To", " " + message.headers.get("Message-ID"));

Likewise when I send from OUTLOOK the header is Message-ID:\n\t<MESSAGE_ID> and by adding those characters I was able to reply to my OUTLOOK email.

msg.setHeader("In-Reply-To", "\n\t" + message.headers.get("Message-ID"));

Alternatively if this is intended, what’s the best way of handling this?

2 Likes