Office 365 (exchange) modifies email headers
In my application's backend (Django) I send emails to contacts. I sometimes expect contacts to reply those emails (helpdesk application).
Using classic SMTP/IMAP-POP email server (hosted on OVH) everything works fine.
I use References
and Message-ID
headers when sending emails, and use In-Reply-To
as well as References
to identify inbound messages and find the source ticket (I keep message-id on ticket and related messages).
But when I added O365 Exchange support, whereas it's still able to send and read emails, everytime it was creating a new ticket instead of a new message in an existing ticket.
I spent time troubleshooting the issue and found out that my custom References
and Message-ID
were renamed by respectively x-references
and x-message-id
, and their value was replaced by Microsoft ones.
So of course, when replying I wasn't able to find back the values I expected. And furthermore, those x-references
and x-message-id
were not coming back with the reply.
Whereas I found a trick to make it work again, with some extra code (I use an alias in Reply-To
e.g.: support+ticket-12345@mydomain.com
which enables me to find the ticket back), it is ugly and people might be tempted to use another idea and make a mess, because it's visible in the "to" section when replying the email...
So I was wondering whether there is another way to achieve this. Either by telling Exchange not to replace my header values or by including the x-references
and x-message-id
in the reply headers, which I could find back.
NOTE: I use Python O365 to connect to the mailbox.
Thanks in advance !