1

I have hMailServer installed and want to integrate e-mails into our application. I have set up a prototype which gets all folders (imap_mailboxmsginfo), then gets all messages from all folders (imap_fetch_overview), then gets the data from each e-mail e.g. (imap_body), and I can save these locally.

However, if a user has 10,000 e-mails in 100 folders, and I want to then check to see if he has read a specific e-mail since the last time I downloaded the e-mails from the hMailServer, I have to get all folders, get all e-mails from each, and then search through them for the unique message_id until I find the e-mail in question.

I have to do this since "msgno" is not unique at all, and "uid" is unique only for each folder, and if the user moves an e-mail from one folder to another, it changes its "uid". And there is no way to access the "messageid" that I see in the hm_messages table in the hMailServer database. Therefore, "message_id" seems to be the only way that I can uniquely identify an e-mail, yet I find no PHP/IMAP function which allows me to get a message from hMailServer by specifying the message_id.

Is there a way to either (1) get an e-mail with the message_id from hMailServer, or (2) a way to get notifications from the hMailServer that e.g. a specific mail was deleted, flagged, or moved to another folder? How do PHP e-mail clients solve this issue?

Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047

1 Answers1

0

In the web mail i created, i used both data (message number and folder) for reading and deleting etc and i works well.

If you want to get a unique id for each mail use this function imap_uid. It return the unique id from the mailbox folder and the message number.

In my opinion using the database directly is a bad idea for synchronisation issues either for simple actions or creating routing rules. The only thing i used hmail database is for administration and making statistics.

Kassav'
  • 1,130
  • 9
  • 29