Crystal Grace
Crystal Grace

Reputation: 43

Send email repeatedly

I am currently creating a system in my internship using Codeigniter. This system will be able the user to create a service request. After creating the request, an email will be sent automatically to the approver(another user), to notify him of the request. (This has already been implemented). Then the approver will decide whether to approve or disapprove the request. Now, my new assignment is that the approver will receive frequent notifications in his email ( every 30 mins) if he still hasn't approve/disapprove the request in the system. How will I make this possible?

Upvotes: 0

Views: 95

Answers (3)

jagad89
jagad89

Reputation: 2643

you need to create a controller with a function which check status of approval and send email if not approved.

eg.

class checkapproval extends CI_Controller {

    public function index()
    {
      // Database query to fetch all pending approval.
      // $records = $this->db->where('status !=','approve')->get('table_name');
      // foreach($records as $record){
      // send email
      // updated email timestamp in databse for record
      // }
    }
}

Now, our next step is to execute this index every 30 minutes. Here's cron job we required.

we need to set command in cron job as below which executed every 30 minutes.

$php /path/to/project/index.php checkapproval index

for more details regarding codeigniter CLI look HERE

Upvotes: 1

OlajosCs
OlajosCs

Reputation: 231

You should use a cron job to perform this. A script which checks whether there is unhandled request or not. Then if he has unhandled request, send him an email.

Upvotes: 0

Nikster2014
Nikster2014

Reputation: 409

You will need to have a field in your DB against this user which counts the number of times he has been emailed and the timestamp when the last email was sent....and then a cron-tabbed script (running once every 30 mins) will check to see if the user has taken action on the request....and if not; send out another email and update the DB fields with the number of emails sent (incremented) and the unix timestamp when the new email was sent out.

Upvotes: 0

Related Questions