EmailReplyParser icon indicating copy to clipboard operation
EmailReplyParser copied to clipboard

Feedback: why and how are you using this lib?

Open willdurand opened this issue 10 years ago • 41 comments

Hi!

I must admit that I never used this library myself, I just took a couple hours to port the GitHub's email_reply_parser library because it looked cool. Earlier this week, I decided to read the code again, and it was quite awful, so I refactored the lib, and I shipped 2.0.0. I hope you will like it.

Anyway, if you are a user, I'd love to hear from you! Could you please write a comment below, telling me more about your use cases, why and how you are using this lib, and maybe some ideas or things you would love to see in it?

:heart: Thank you! :heart:

Will

willdurand avatar Dec 03 '13 16:12 willdurand

Doh! No comment yet.

willdurand avatar Dec 16 '13 14:12 willdurand

We're using it! It is crucial piece in a system that, similar to GitHub and other services, allows users to reply to email notifications/messages and have their replies inserted back into our messaging system (after being parsed thanks to your library).

What I have found is that your library does about 95% of the parsing work. The other 5% would be the extra handling for edge cases and poorly formatted emails that are frequently sent in the Real World™. Over the course of the past several months we've collected the major offender patterns and run an extra series of 10 or so preg_replace() calls after your library has run in order to filter all those misc pieces out as well.

For a future idea, figuring out a way to handle these cases in the library would be handy. Perhaps an extra "trim liberally" option that can tell the class to incorporate a bunch of these regex patterns and filter them out automatically. Or perhaps a way to pass a series of extra regex strings for the library to look for.

Anyhow, thanks for the library and keep up the great work!

soundslocke avatar Jan 03 '14 16:01 soundslocke

@soundslocke thank you for your feedback, much appreciated :heart:

Adding a way to hook into the parsing process sounds like a really good idea, and if you have ideas on how to introduce such a feature in the lib, please don't hesitate to submit a patch, even if it is just a draft :)

willdurand avatar Jan 05 '14 04:01 willdurand

@soundslocke could you perhaps paste your regexs? So that we can learn from it :-)

@willdurand I will start using your lib right now. I have a messaging system on my website and would like people to be able to respond from their email client.

I have some future features where people will be able to perform actions on notifications from their email.

andheiberg avatar Feb 10 '14 19:02 andheiberg

Sure, though I can't paste all of them because they are specific to us. Here are the more common ones I can share though:

$parsed_message = preg_replace('/\n(\s?)In a message dated(.*?)$/si', '', $parsed_message);
$parsed_message = preg_replace('/-----Original Message-----(.*)/si', '', $parsed_message);
$parsed_message = preg_replace('/-------- Original Message --------(.*)/si', '', $parsed_message);
$parsed_message = preg_replace('/Sent from my Verizon Wireless Smartphone(.*)/si', '', $parsed_message);
$parsed_message = preg_replace('/Sent from my Galaxy(.*)/si', '', $parsed_message);
$parsed_message = preg_replace('/Sent from my PANTECH(.*)/si', '', $parsed_message);

soundslocke avatar Feb 10 '14 19:02 soundslocke

Thanks

andheiberg avatar Feb 10 '14 20:02 andheiberg

I'm using your library in a CRM, to extract the real content of messages from customers. Then the system updates conversations in database. Operators can see messages and reply from a backend.

It would be nice to have a feature to clean subject, e.g.: remove Re:.

yosmanyga avatar Feb 17 '14 16:02 yosmanyga

We are a user experience/research firm and use your product in combination with tedivm/fetch to parse incoming e-mails from research participants. Since most people here are sharing their solution for custom regular expressions, thought I'd share ours here as well. We chose not to do some additional parsing afterwards, but extend the library like this: https://gist.github.com/bjornpost/c4873ba9690b3ca15d66

It would be nice though if it wouldn't require subclassing 2 classes, but instead just load another parser from the EmailReplyParser class.

bjornpost avatar Feb 25 '14 19:02 bjornpost

@bjornpost fetch looks interesting... does it simply give you all unread messages in the inbox? and then mark them read?

andheiberg avatar Feb 25 '14 21:02 andheiberg

@AndreasHeiberg https://gist.github.com/bjornpost/8a54fa94e17c7600cd50

bjornpost avatar Feb 25 '14 21:02 bjornpost

Nice, thank you!

willdurand avatar Feb 26 '14 08:02 willdurand

Injecting a new parser looks like a nice improvement :)

willdurand avatar Feb 26 '14 08:02 willdurand

I have waited pretty long for a project where I could use it actually - and now it came.

Though its just for internal fun, for our "send a email to our office screen".

But I can see there are missing a pretty crucial test, UTF8 characters there are converted to ISO-8859-1 (or the other way round) - this gives some very strange characters.

I will fork and create a test fixture for this and see if it fails :)

lsv avatar Sep 18 '14 15:09 lsv

@lsv yep, don't hesitate to create a Pull Request with either tests or tests + patch :-)

willdurand avatar Sep 18 '14 15:09 willdurand

@willdurand ohh, I forgot that it was the subject that have trouble with ISO-8859-1 > UTF-8

protected $subject =>
    string(37) "Heja med =?UTF-8?B?w6bDuMOlIGRpZw==?="

(should be) Heja med æøå dig

So well its out of this repos scope :)

lsv avatar Sep 18 '14 20:09 lsv

Is exist any parser for email forward ?

pbrzoski avatar Jan 09 '15 14:01 pbrzoski

You rock!

We use this in combination with postmarkapp service to extract the signatures from incomming mail.

I noticed you have french support in the regexp. How about swedish? Or some way to add them.

example from apple mail client: 5 mar 2015 kl. 12:03 skrev {joe}

cristobal-wetzig avatar Mar 05 '15 12:03 cristobal-wetzig

If you want, you can create pull request with swedish.

Regexps for other language, are in file src/EmailReplyParser/Parser/EmailParser.php

pbrzoski avatar Mar 05 '15 15:03 pbrzoski

Yes, adding swedish is ok. But there is also a method for that IIRC.

willdurand avatar Mar 05 '15 16:03 willdurand

Thanks for the kind words btw :)

willdurand avatar Mar 05 '15 16:03 willdurand

@willdurand m8 if you ever in Stockholm, a cold beer is waiting for you.

cristobal-wetzig avatar Mar 05 '15 16:03 cristobal-wetzig

I've been using EmailReplyParser for quite a while now, but must have missed this issue previously!

We're using it in a WordPress plugin called Falcon that allows people to reply by email. Super handy when using a WordPress site as an internal company message board (with something like P2).

EmailReplyParser means we can have minimal effort when replying for a basically seamless integration. Thanks for maintaining this. :heart:

rmccue avatar Oct 01 '15 01:10 rmccue

I'm going to use it for our ticketing service. As you may know major services like Zendesk use a string like "## Please type your reply above this line ##" and when user click reply button this string is above all quoted lines. It's a good idea to accept a string and put all below lines in a quoted fragment.

miladr avatar Nov 16 '15 14:11 miladr

Hi, thanks for your work on this lib.

We use this lib for our internal ticketing system, we parse emails inputs directly to tickets and we "clean" these emails thanks to EmayReplayParser.

Regards,

lflaszlo avatar Nov 23 '15 08:11 lflaszlo

We use it as a very important component of our SaaS business -- https://supportyard.com. And we love it!

perajovic avatar Feb 29 '16 16:02 perajovic

Thank you for your replies.

willdurand avatar Jul 18 '16 07:07 willdurand

I use it in our production code to parse e-mail messages. It's immensely valuable, but I may need to add more detection scenarios for more languages since we deal with a lot of different languages.

SGudbrandsson avatar Nov 09 '16 10:11 SGudbrandsson

We use it in our ticketing system to parse the replies we get through emails.

dbr0 avatar Jan 03 '17 17:01 dbr0

Thank you so much for this! Amsterdam is very happy with your work. Using this to send chatbox messages via email.

voicecode-bv avatar Jan 24 '17 21:01 voicecode-bv

Dear users, 2.6.0 is out today. Thanks!

willdurand avatar May 24 '17 08:05 willdurand

This class looks great! Question though - we need something like this to parse e-mail replies inbound from Sendgrid. We want to extract just the reply and not all the quoted content in the chain.

But this class only parses plaintext email, right? When users reply they are using their own mail clients. I know that Sendgrid provides the plaintext content if available, and in my tests I see that Gmail and Thunderbird do by default include the plaintext alternative. But I don't know whether to assume most email clients will.

What do people do about this? How do we best ensure we can feed plaintext replies into this parser? Thank for any advice!

thebordella avatar Jun 20 '17 22:06 thebordella

@thebordella

$plain = html_entity_decode(
    trim(
        strip_tags($html)
    )
);

spidgorny avatar Jan 23 '18 14:01 spidgorny

Hi

I'm a developer for the EmailReporting project which is a plugin for MantisBT.

I'm planning to use this library to process incoming emails more effectively and create better tickets or notes for MantisBT

I'm already using Markdownify to process html emails to markdown. I wonder how well EmailReplyParser handles that content. We'll see. If succesfull this will retire more simple existing code in EmailReporting

SL-Gundam avatar Jan 24 '18 13:01 SL-Gundam

Hi @willdurand , I am not using it myself, but was trying to help someone. As others already mentioned, it is to make it similar to github notification reply to email sort of stuff.

  1. Probably finding attachments would be a nice feature.
  2. As already mentioned attaching more parsers would be a nice feature to have.

harikt avatar Mar 16 '18 04:03 harikt

Using this to import emails into a ticket and rma system. Had written something close myself until I realized how many various formats are in play. A quick search brought me here from this stackoverflow answer.

Your work is much appreciated!

billynoah avatar Mar 21 '18 07:03 billynoah

I'm using this to process inbound emails for tickets/replies, so useful to just get the reply part. I added this lib to https://github.com/beyondcode/laravel-mailbox/pull/7 to make it easier to process Inbound replies in Laravel.

What would make it easier to maintain perhaps, is making it possible to add custom signatures manually (eg $parser->addHeaderRegex($pattern)).

Are you still maintaining this, because it still looks like one of the best available packages in PHP.

barryvdh avatar Feb 19 '19 08:02 barryvdh

Oh my bad, there is actually getQuoteHeadersRegex() and gsetQuoteHeadersRegex() already :)

barryvdh avatar Feb 19 '19 08:02 barryvdh

And just as a FYI, I did some digging and most libraries support only English (like Github). The discourse reply trimmer is more extensive (and multi language) it seems: https://github.com/discourse/email_reply_trimmer So perhaps for a future version, we could take a look at which regexes etc they use, or copy over the tests.

barryvdh avatar Feb 20 '19 08:02 barryvdh

Are you still maintaining this, because it still looks like one of the best available packages in PHP.

I am, at a very very low pace.

Thanks for using this lib!

willdurand avatar Feb 20 '19 09:02 willdurand

We use this in Eventum Issue Tracker to collapse quoted replies like GMail does:

  • https://github.com/eventum/eventum/pull/143

glensc avatar Mar 24 '20 20:03 glensc

I'm using it with great success for the open source groupware for collectives called Agorakit : https://github.com/agorakit/agorakit

And, really thank you for this tool, in short, the best option for php !

philippejadin avatar May 04 '21 07:05 philippejadin