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:

  1. Check that the subject contains the word "Welcome!"
  2. 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:

  1. Dynamic
  2. 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?

  • 3
    Sounds like a good use case for a Rules Engine. – Greg Burghardt Mar 6 '19 at 20:29
  • @GregBurghardt Seems like what I need. I found Hoa/Ruler project, which is a ruler for PHP. My question is - should I store each users "unique" rules in a database? – oliverbj Mar 7 '19 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.