Open iamved777 opened 1 year ago
(ignore earlier response - I answered a different question!)
First of all; the uniqueid is for the internal MIME boundary purposes, it had nothing to do with the last message id you want to get. So, please disregard that route!
Next; prerequisite for a message id is that the mail was sent successfully, so you need to be sure it actually does, by checking the boolean result of $mail->send();
Now; setting the message id is the responsibility of the actual SMTP server sending the email. PHPMailer can only retrieve it if it was set properly. If not, PHPMailer can not do anything about that and can not do anything else than returning an empty string.
That said; a second route is to use the transaction id!
By calling / echoing $mail->getSMTPInstance()->getLastTransactionID()
That might suit your needs and goals and should work in your example data.
When I enable $mail->SMTPDebug = 4, Its always showing me like
2023-07-26 15:32:15 CLIENT -> SERVER: Message-ID: <fDFVyMqcOINam0sYNVGdDtEXPhvrxBk2sL0qlmqsj4g@myserver.com>
But when I var_dump($mail)
Message ID getting empty. Even I check in Gmail Show Original, Its there but I am not getting it with any method. I have tried $mail->getSMTPInstance()->getLastTransactionID() but its also empty.
Thanks!
I have also marked that
uniqueid =fDFVyMqcOINam0sYNVGdDtEXPhvrxBk2sL0qlmqsj4g
Message-ID (I can seen in Gmail Show Original) = <fDFVyMqcOINam0sYNVGdDtEXPhvrxBk2sL0qlmqsj4g@myserver.com>
so if I can retrieve uniqueid , I can join and use it as Message ID ? If Yes, Please give me the way to retrieve uniqueid From $mail.
Thanks!
@iamved777 did you figure it out?
I am trying to get last message id from PHPMailer when its send email. My Code is looks like
When I echo $mail->getLastMessageID() its always empty but when I var_dump($mail) I have array like below.
Here uniqueid at the last is same like message id which I want. But since its protected object, I am not able to retrieve it. Let me know if anyone here can help me for solve the issue. Thanks!