1

i am doing a project where i need to notify a user through email if his account has expired, that is when a user signsup his sign up date and expire date is inserted into the database

now what i need to do is , i need to fire a function when the users expire date is passed and send an email notifying user about the expiration of his account . and this needs to be done automatically through the function .

how can i achieve this ?

jarus
  • 1,853
  • 11
  • 44
  • 76

5 Answers5

1

The simplest thing to do is create a basic cron job that runs on a regular interval (like hourly or daily) that runs a PHP script that queries the database for any newly expired users and then emails them.

Ben Hughes
  • 14,075
  • 1
  • 41
  • 34
1

You can have a cronjob that runs every hour or so (or quicker if you need to). This cronjob would run a PHP script that gets a list of all expired accounts and sends emails to them.

Here's a tutorial on how to use crontab.

Here is a SO question on Cronjob and PHP

Community
  • 1
  • 1
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
0

Write a cron job (running as often as you think appropriate) to call a script (possibly PHP CLI) that does a select for all expired accounts and mails them. And what does this have to do with JavaScript?

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
0

Probably the easiest way to do this would be using either at or cron. Either one of these could be set up to call a PHP or whatever script at the time of expiration, or it could be just run once an hour, each time checking if there are any newly expired entries.

A less efficient approach would be to have the header or footer script of your pages to check the database every time any page is loaded, but I would not recommend this approach unless you absolutely can't use cron or at.

Mark Rushakoff
  • 249,864
  • 45
  • 407
  • 398
0

By the way, if you are not using a unix / linux system but a Windows one, you could use Scheduled Tasks and call a script.

nairdaen
  • 1,037
  • 2
  • 11
  • 19