Welcome Guest, Not a member yet? Register   Sign In
How to parse replied email and insert into database
#1

[eluser]mDonchev[/eluser]
Hi Guys,

I need to do some extra functionality to my web application.
I have a discussions posts and each time a user post something there, I send a notification email to all other users. I need to make the following functionality too:

- When a user replies to the notification email with some text, this text to appear on the discussion.

I know I have to regularly check the POP3 account for any replied emails and probably to use the subject line to get the topic ID which I need for my insertion but... I wonder how I will parse the replied email body, to get only the new text out of the whole text of the email.

Anyone with an idea?

Thanks in advance,
Martin
#2

[eluser]bretticus[/eluser]
If your discussion is threaded, you can send the email with the ID for the current thread. That way you only have to compare the last thread if your email ONLY contains the last thread in the initial notification. If you're going to include them all, you could (and this is off the top of my head) strip all alphanumeric characters from the post initially and take a hash and store that in the database. Next, you'd have to do the same stripping and loop through the returned email looking for expected patterns and reducing the text (ouch!) Even then, I'm not sure that's fool-proof. Perhaps just pay attention to the several systems out there that already do this and see if perhaps, there's some patterns to detect quoted text, etc.

Quite a problem. Good luck!




Theme © iAndrew 2016 - Forum software by © MyBB