I’m sending email to users with Laravel. It’s working fine.
So I’m now reading my inbox with PHP-IMAP to catch users email responses.
How can I identify an incoming email to the previous sent message?
I tried using mail header: $headers->addTextHeader('X-request_id', $request->id);
The header is correctly sent to user but in response message the header is not present anymore.
Any suggestion?
Advertisement
Answer
I am pretty sure that there is no way to preserve headers so that the same header is returndes in a reply.
the simple solution:
A lot of bug tracking software systems use an id in the subject or the text of the email e.g. the case number and parse the case number from the subject. this will survive all kinds of mail systems spam and virus checkers and more.
A different approach would be to create specific email adresses including the id inside the email adddress for each email. But this is far more complicated.
A similar way is used if you have internal messages from user to user that are sent and can be replied by email. so user34@users.example.com sends an email to user 3432@users.example.com If you want to prevent email disclosure.
Then you would need either a service like cloudmailin or your own mailserver with the necessary logic.