I need a pattern for processing incoming emails.
My current pseudo-code is like this:
if sender is [email protected] and messageBody contains "aaa" then
extract the content according the aaa function
save it to database
move the message to the archive
else if messageBody contains "bbb" then
extract the content according to bbb function
save it to database
inform sender
move the message to archive
else if messageBody NOT contains "ccc" and from "[email protected]" and then
leave message in the inbox so the it will be manually processed
else if ...
...
So, I ended up with a pig function with thousands of lines.
How can I make this thing simpler?
Thanks in advance
A very good architecture is required for solving this problem, machine learning is one of the best solution for this kind of problems. But still there are some things that you can take care of, in order to make it simpler.
Rather than putting 10 ifs for 10 email-ids, create a list of unwanted users (which will go in spam)
Create a list of unwanted subjects
Create groups of time intervals and process emails accordingly; morning emails, noon emails, evening emails etc
create has attachment check
no subject check
no body check
friends email list
same domain email-id sender check
Thanks. :)