I'm sending e-mails with Sendgrid. When the recipients reply to the mails, Sendgrid will parse the reply and POST to my webhook.
How can I relate the reply to the original message, so that I have a message thread?
I'm thinking that this may be possible using X-SMTPAPI headers and unique_args.
Update: I think this is how I did it (but it was a while ago)
$arguments = ['unique_args' => [
'sentMessage_id' => $this->sentMessage->id,
'tenant_id' => \app('currentTenant')->id,
]];
$header = \json_encode($arguments);
$this->withSwiftMessage(function ($message) use ($header) {
$thread = $this->sentMessage->message->thread;
$headers = $message->getHeaders();
$headers->addTextHeader('X-SMTPAPI', $header);
$headers->addTextHeader('References', "<{$thread->first_mail_reference}>");