This topic is locked
[SOLVED]

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

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

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]
Phone[555-555-1234]
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:
https://stackoverflow.com/questions/1462720/iterate-over-each-line-in-a-string-in-php

need2sleep authorDevClub member 8/12/2021

Thank you for the direction. This will help