Sending mail, problem with message_id

I’m sending mails from my apps using both “mydomain.com” 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, https://forum.yiiframework.com/t/swiftmailer-message-id/124475/8.

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(); 
                $message->setFrom($model_m->mailaddress);
                $message->setTo($model_m->receiver);
                $message->setSubject($model_m->subject);
                $message->setTextBody($model_m->body_plaintext);
                $message->setHtmlBody($model_m->body_html);
                if ($message->send()) {
                          // store data in db
                }

update:
i managed to force an id.

$message->getSwiftMessage()->setId(‘properlyformed@message.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?