This topic is locked

EmailReader Template - Parsing message body to extract text into certain fields

8/2/2021 10:14:54 AM
PHPRunner General questions
need2sleep author

I was wondering if anyone uses the EmailReader template to extract text to custom fields.

The EmailReader template will extract different parts of the email (email, body, attachements etc) to a separate field in the table but, I'm looking to extract even further from the body of the email.

For example, when we receive a website lead through email like:

Name[John Smith]
Message[Looking to purchase your service]

How can we get the EmailReader to parse through and add the 3 text items into 3 separate fields in a leads table "Name,Phone,Inquiry".

I suppose the other option would be to have a form on the website to store the leads directly to the database but this would skip the spam checkers.

Any advice would be greatly appreciated. Thanks!

admin 8/2/2021

EmailReader template has an option to call a custom PHP function when a new email arrives. You can use it to parse the message body and do something useful with it.

Check section named "How can I execute some code when a new email arrives?" at the end of this page.

Also a couple of relevant PHP examples like how to parse the large text line by line:

need2sleep author 8/12/2021

Thank you for the direction. This will help