Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mimic ticket system email-to-post functionality

Tags:

php

email

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.

like image 554
Patrick Avatar asked Mar 06 '26 05:03

Patrick


1 Answers

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.

like image 194
Jesse Cohen Avatar answered Mar 07 '26 17:03

Jesse Cohen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!