Reply to previously sent email


I’m trying to send and email, and later send a reply to that same email.

import { Email } from 'meteor/email';

const messageId = 'some-random-string';
  subject: 'Test',
  from: '<from-email>',
  to: '<to-email>',
  text: 'some text',
  messageId: messageId,

// later in time
  subject: 'Text',
  from: '<from-email>',
  to: '<to-email>',
  text: 'more text',
  inReplyTo: messageId,

It’s not working because the message id I’m using is sent as “X-Google-Original-Message-ID”. Is it possible to get the message id of an email after sending it? Or alternatively generate a valid message id so that gmail won’t replace it with its own id?

From Wikipedia:

Message-IDs are required to have a specific format which is a subset of an email address [2] and to be globally unique. That is, no two different messages must ever have the same Message-ID. A common technique used by many message systems is to use a time and date stamp along with the local host’s domain name, e.g., [3]

It sounds like your Message-ID needs to have an @domain block added to be correct

Which seems to be confirmed by this question on SO:

(incidentally, including the portion of a message ID appears to be vital. Without that, using e.g. foobar-123-0 , our SMTP server simply ignored it and used it own autogenerated message ID)

Although the accepted answer says that gmail doesn’t care anyway:

The answer to why they are not threaded in Gmail is because Gmail’s threading is done according to the subject of the messages (it is not based on the “in-reply-to” or “references” field in the header).

So maybe you just have to try subject: `RE: ${subjectLine}` as well?


Adding the domain and using the same subject works:

let messageId = `${new Date().getTime()}-${projectId}@mydomain`;


1 Like