Search code examples
phpimapemail-headers

imap_headers return string format


I'm trying to fetch all mail headers from an inbox using imap_headers($imap_resource) which returns an array of formatted string.

I want to know the proper/correct format of that returned string so I can parse/decode the string and break it down into date/subject/sender, etc.

Someone knows about this?

thanks


Solution

  • Just use imap_mime_header_decode(string $text) for this.

    This will return an array of objects, where each objects has two properties: charset and text. You can start doing that and use php string functions to get what you wanted.