What is the best way to parse email contents? For example, we want to be able to parse emails that are sent from 3rd parties and put them into a database. Right now we use Google Hosted accounts and we were thinking about maybe using PHP IMAP functionality to pull emails every couple minutes and parse their contents, putting it into our DB.
Wondering if that is overkill? If we sent the emails to a dedicated server would there be a way to grab and parse them with PHP?
Not sure how ticketing systems do it... put they allow you to create a ticket by sending an email to a specified address.
If you send the e-mails to a server, you can actually just set your forward file to pipe the e-mail to your parsing script by placing the following line in the .forward file of the e-mail account on the server:
| php createticketfromemail.php
That way you don't have to periodically poll, whenever an email arrives it will be piped to your script.
http://www.softpanorama.org/Mail/pipes_in_dot_forward_file.shtml
EDIT
To address the point that @miemos brought up in his answer. You can structure your forward file to both store a copy of the email in your inbox and pipe it to the script, that way if the script fails you will still have a backup copy of the email somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With