Thursday 15 March 2012

parsing - email parser or php imap functions? -


I am a very reliable way to recover data from email titles. Should I use an e-mail parser like, for example, or the php imap function is enough? What is the best practice? Have any experience? I can imagine that there is a lot of difference in the formatting of email headers created by many email clients, this is why I want a reliable solution.

I used the built-in IMAP functions for the project processing emails by their dates and actually There was no need for anything else you could try and see if they are useful to you with the code given below;

  & lt ;? Connect to Php / * gmail / / hostname = '{imap.gmail.com: 993 / imap / ssl} inbox'; $ Username = 'user@gmail.com'; $ Password = 'pass123'; / * Try connecting * / $ inbox = imap_open ($ hostname, $ user name, $ password, OP_READONLY, 1) or die ('Can not connect to Gmail:'. Print_r (imap_last_error ())) ; $ Email = imap_search ($ inbox, 'ALL'); / * If emails are returned, cycles through each ... * / if ($ email) {foreach (Email $ email_number as email) {echo imap_fetchbody ($ inbox, $ email_number, 0); Echo imap_fetchbody ($ inbox, $ email_number, 1); Echo imap_fetchbody ($ inbox, $ email_number, 2); }} Imap_close ($ inbox); ? & Gt;   

The hard part imap_fetchbody ($ inbox, $ email_number, 0) is. This part will return headers once you receive them, you can choose it or use it.

Hope this will be helpful.

No comments:

Post a Comment