I created an emailer that checks when was the last time a user logged in, if the user didnt log in for 10 days it sends him/her an email. Now I want the system to check if that same user does it twice, and email them a different email. table 1 users:
id - name - loggedindate
0 john 7/11/2012
1 mark 7/6/2012
2 johnny 7/6/2012
3 bruce 7/2/2012
table 2 mailer fields are as follow:
id - days -emailtosend - numberoftimeseventhappens
0 4 hello 1
1 4 blabla 2
2 6 example 1
3 3 to 1
4 4 demonstrate 1
so here for example mark and johnny didnt log in for 4days.
the first time that event happens it sends them the email "hello"
the second time the event happens the emailer needs to send them "blabla"
so lets say mark doesn't log in for 4days,first email will go
then he logs in on day 5, then after another 4days he doesnt log in, I want to send him the second email that would be ID=2
on table 2
the file runs on a cron and checks every 2 hours
any ideas on how to do it ? I just need the way to do it not the actual code I can write it myself, I ve been pulling my hair over this one.