Identify issue id from mail header(Message-ID and References fields)

I have implemented this by storing the message-id in a database table and comparing it with the References field of the incoming mail. Please review. Refer: http://www.mantisbt.org/bugs/view.php?id=16719