EmailReplyParser
EmailReplyParser copied to clipboard
Feedback: why and how are you using this lib?
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
Doh! No comment yet.
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 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 :)
@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.
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);
Thanks
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:
.
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 fetch looks interesting... does it simply give you all unread messages in the inbox? and then mark them read?
@AndreasHeiberg https://gist.github.com/bjornpost/8a54fa94e17c7600cd50
Nice, thank you!
Injecting a new parser looks like a nice improvement :)
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 yep, don't hesitate to create a Pull Request with either tests or tests + patch :-)
@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 :)
Is exist any parser for email forward ?
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}
If you want, you can create pull request with swedish.
Regexps for other language, are in file src/EmailReplyParser/Parser/EmailParser.php
Yes, adding swedish is ok. But there is also a method for that IIRC.
Thanks for the kind words btw :)
@willdurand m8 if you ever in Stockholm, a cold beer is waiting for you.
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:
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.
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,
We use it as a very important component of our SaaS business -- https://supportyard.com. And we love it!
Thank you for your replies.
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.
We use it in our ticketing system to parse the replies we get through emails.
Thank you so much for this! Amsterdam is very happy with your work. Using this to send chatbox messages via email.
Dear users, 2.6.0 is out today. Thanks!
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
$plain = html_entity_decode(
trim(
strip_tags($html)
)
);
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
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.
- Probably finding attachments would be a nice feature.
- As already mentioned attaching more parsers would be a nice feature to have.
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!
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.
Oh my bad, there is actually getQuoteHeadersRegex()
and gsetQuoteHeadersRegex()
already :)
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.
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!
We use this in Eventum Issue Tracker to collapse quoted replies like GMail does:
- https://github.com/eventum/eventum/pull/143
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 !