Re: [gkornbluth] Automatic emails before account expiration
Hi Jerry,
It's always a bit tricky to send emails at set intervals and track it, but here's one way:
- You add a checkbox called: preExpiryReminderSent
- And add a checkbox called: expiryReminderSent
- You make a php script that runs as a cronjob once daily
- You load all the users where (this is pseudo-code):
(expiryDate - x days) < NOW AND preExpiryReminderSent != 1
and for each user send an email and then set the preExpiryReminderSent =1
- Then load all the users where (this is pseudo-code):
(expiryDate) < NOW AND expiryReminderSent != 1
and for each user send an email and then set the expiryReminderSent =1
- Then when they renew set both those checkboxes to 0
Note: When testing email code, test it well and output the results to the screen first with "Sending reminder to email@example.com" so you can work out any bugs without spamming your users.
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com