Search code examples
phpphpmailer

retrieve $MessageID from phpmailer


I have just set up phpmailer, and i want to store messages in a log table on send.

phpmailer creates a messageid automatically, how can i retrieve $MessageID it so i can store it in my table ?

i don't need to set it, but i tried this...

$MID = time() .'-' . md5('[email protected]' . '[email protected]') . '@domain.com';
$mail->MessageID = $MID;

and the header on the sent email is different

would be happy just to retrieve the default one


Solution

  • There is a method getLastMessageID that you can use.

    How about setting your own value? You must remember, that

    the structure of MessageID should be:

    <sometext@sometext>

    If your MessageID doesn't have this exact structure - PHPMailer will ignore your MessageId and generate it's own MessageId.