You can't get the message ID for mail sent via the mail()
command. That message ID is generated by sendmail, or whatever else is downstream.
You would need to use something else to generate your mail with, such as PHPMailer, or one of the many other alternatives.