How do I override the Message-ID header of wp_mail function?

You can filter the $phpmailer object. Something like this should do the trick (not tested):

add_action( 'phpmailer_init', 'wpse_52555_msg_id' );

function wpse_52555_msg_id( &$phpmailer )
{
    $msg_id = get_post_meta( get_the_ID(), 'messageID', TRUE );
    '' !== $msg_id and $phpmailer->MessageID = $msg_id . '@test.com';
}

Leave a Comment