PaperBagged
PaperBagged

Reputation: 177

Sending E-mail When Sessions timestamp is 90 min old

I have a mysql db that gets populated with the session info below called my_active_users

username    timestamp      email
MyName      1351121630     [email protected]

How can I send up a trigger to send a e-mail to the user when the session timestamp is over 90 min old?

I already have the mail.php set up to send the e-mail with the proper content just not sure how I would link or trigger the mail to be sent to the users who have not been active for 90 min.

Any help would be greatly appreciated.

Upvotes: 0

Views: 155

Answers (1)

nickhar
nickhar

Reputation: 20823

Agree with @nickb,

Write a script (pseudo-code here):

SELECT user, firstname, lastname, email
from sometable 
where timestamp > (current_time - 90mins) 

Then personalise and send using your mail.php script.

Where the crontab is concerned, I don't know how much you know about it, but, you can either execute it via PHP or a service like wget (or lynx etc):

PHP:

*/10 * * * * /usr/bin/php /path/to/script/script.php

Or via URL request:

*/10 * * * * /usr/bin/wget -q -O http://www.domain.com/script.php > /dev/null

Both of the above request every 10 minutes, but you can change to fit your requirements.

Hope this helps.

Upvotes: 1

Related Questions