I am currently trying to create a web application, that saves inbound emails. I have figured out how to save the incoming emails into my database, and I have all the email information available (headers, body etc.)
I want to be able to allow my users to set custom conditions for each of the email inboxes they have. So image user A have three inboxes. User A decides that for Inbox 1, below rule should apply:
Meaning that the script, in this case, should:
- Check that the subject contains the word "Welcome!"
- Check that the From message does not contain the word "@hotmail.com"
Now I know I can just write a "simple"
ifstatement, but this will not solve my problem, as I need it to be:
- Specific for the given inbox
I am not sure how to go around this. My first thought was to add the custom conditions for the inbox in a database (maybe in an array), and call that array on every incoming e-mail, and then maybe write custom methods for each specific rule I allow users to choose.
However, I am not sure if this is a good idea or seen as good practice?