With PHPMailer, when you do ->send()
, it appears to not send any kind of "information" back except true/false: https://phpmailer.github.io/PHPMailer/classes/PHPMailer-PHPMailer-PHPMailer.html#method_send
I'm trying to get the "Message-Id" immediately back from the server when I send the e-mail. I need this in order to enter into my database to track the outgoing e-mails.
Yes, I insert the records into my database when I fetch the actually sent e-mails from the IMAP server, but I need to know what the Message-Id is so that I can verify automatically that it has been sent and whatnot, and not have to always look in my "sent" folder of my e-mail client to make sure it was actually sent (and thus fetched as a "sent" e-mail).
If this doesn't make sense, then at least know that I need to "track" it, but PHPMailer doesn't appear to send back any kind of information unless there is an error.
How do I get the Message-Id immediately when sending an e-mail with PHPMailer?
My Answer:
$mail->send();
You can retrieve the Message-Id of the sent email by accessing the property $mail->MessageID. This property will contain the Message-Id of the email that was sent.
Rate this post
5 of 5 based on 9385 votesComments