0

I'm running a service where users receive an email every day at the same time, to which they reply (to an unmonitored email account).

I want to capture the following pieces of information from those replies and insert them into a database:

  • the sender's email address
  • the sender's message (minus the rest of the thread or any email signatures)
  • the date (YYYY-MM-DD) of the original email to which they are replying

I gather email piping is one solution, and I've found some libraries which can do the basics, but nothing as complicated as getting the date of the original message, for example.

I'm using PHP but am open to whichever language can achieve this the easiest.

Update:

I'm using MailChimp to send the emails, so maybe I could include something like <span id="YYYY-MM-DD"> using merge tags that the parser searches for?

Sebastian
  • 3,548
  • 18
  • 60
  • 95
  • For the date thing, you're better off passing an ID in the subject that you store and may query later on. Otherwise you'll be spending time trying to parse HTML which is not fun. Have you seen the function [imap_search](http://php.net/manual/en/function.imap-search.php)? – IsThisJavascript Jan 04 '18 at 10:02
  • To remove the signature from an email body; take a look here https://stackoverflow.com/questions/725400/best-way-to-chop-a-signature-off-an-email-body – IsThisJavascript Jan 04 '18 at 10:05
  • @IsThisJavascript what do you mean exactly? Having the date in the subject line that's sent to users that can then be pulled out of the reply? – Sebastian Jan 04 '18 at 10:34
  • When you send the email to the client; generate an ID like "asguyac1361za" store it in your database then send it in the subject. When you come around to filtering your emails you can parse the subject, pull the ID, query the database and find out why you sent the email in the first place, aswell as what date – IsThisJavascript Jan 04 '18 at 11:06

0 Answers0