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
}