I just encountered an internal server error by simply calling
$eml = mailparse_msg_parse_file("$path/eml/$email_id.eml");
The error disappeared after adding
mailparse_msg_free($eml);
to the end of the script.
Without mailparse_msg_free i keep getting an internal server error.