Search code examples
phpemailimap

How to fetch email headers properly


I'm using imap_fetchheader() to retrieve header info of an email message. For some emails this message id is empty. But when i check the same email through webmail message id is present.

Is there anyway to fetch all header info without any issues?


Solution

  • The issue here is not with the imap_fetchheader() . Message in email header will be like this:

    <[email protected]>
    

    I think, for some message ids, browser thinks it as html tag and prints. Issue resolved when i convert it using htmlentities() ex:

    htmlentities( imap_fetchheader($conn, "1"))
    

    how silly the answer is...!