Sending mail, problem with message_id

I’m sending mails from my apps using both “” mail and external SMTP servers (e.g. gmail, hotmail…)

i need sent messages ids to save them in my db. The one saved, however, is different from the one received. I have already read an old post, here in the forum,

Saved in DB : abefa4b772788bf3e062a636f5507dc0@localhost
in the real mail headers: VI1P189MB0384B149C0063658E14EAC3FDAE29@VI1P189MB0384.EURP189.PROD.OUTLOOK.COM

I’m developing in my localhost at the moment, but I doubt going in “production mode” should solve this.

here is my code:

 $message= $mailer->compose();
                // Getting message_id here, as suggested in the post i mentioned before
                $messageidihavetostore= $message->getSwiftMessage()->getId(); 
                if ($message->send()) {
                          // store data in db

i managed to force an id.


I found that sending via SMTP through outlook moves my message_id to X-Microsoft-Original-Message-ID field.
How can I manage to thread messages in this way? Every provider modifies message_id field?