使用php跟踪电子邮件[关闭]

I am in a middle of setting up an email system on my project.

There are two ( or more than .. ) types of users on the app. They can send messages to each other ( ...like facebook ). This is fine.

Ex.

User1 send and message to User2, now an email is also sent to User2's personal email.

I know how to read/send email using IMAP/POP, but still i am stuck with how to implement threaded messaging system ? because users can reply to messages through their email (outside of app) ..

Normally i do like to set FROM address something like workspace-ws@mydomain.com so that i have the credentials to log through imap/php.

Here is the problem

When i send an email from one address ( say workspace-ws@domain.com ) i can set a reply-to header, so that any reply's will be sent to workspace-ws@domain.com, this is fine. But how i know that user is replying to which parent thread ? and to which child message.

Is there any other ways to achieve this ? NO , What is the best methods to do this ?

A common way to solve this problem is to setup a mail infrastructure using dynamic email addresses that will be parsed by the server before delivery to the user.

For example you have:

testuser-a > emailaddress testuser-a@test.com
testuser-b > emailaddress testuser-b@test.com

So when a testuser-a sends a message through the system to testuser-b, testuser-b than receives a email from a system identifier instead of testuser-a@test.com. When he replies the email is fetched by the server, parsed (so it can be stored in a database for threaded message overviews, stats etc) and (if required) sent to testuser-a (again with as sender a system identifier instead of testuser-b@test.com).

This way you prevent both users (if needed) from gaining each others real email addresses and you can force all communication to run through the system for further processing.