|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is there a way with PHP to send out a timed, email reminder? For instance,
to send a client an email that their subscription will be expiring in a week - or to send an email a day before an appointment is due. I can see how to do if someone logs in and then I run a appointment checker script - but how to do as a service, or daemon, so it works anytime? -- Dave - Head Developer http://www.blurredistinction.com Adobe Community Expert http://www.adobe.com/communities/experts/ |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"Dave Mennenoh" <dave@blurredistinction.com> writes:
> Is there a way with PHP to send out a timed, email reminder? For instance, > to send a client an email that their subscription will be expiring in a > week - or to send an email a day before an appointment is due. I can see how > to do if someone logs in and then I run a appointment checker script - but > how to do as a service, or daemon, so it works anytime? Normally on Unix/Linux you would use a 'cron' job and schedule it to run daily/hourly/etc.... WHen it is activated you can have it check for reminders or whatever. You can use PHP in the script. Hope this s. -- John __________________________________________________ _________________ John Murtari Software Workshop Inc. jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM) http://thebook.com/ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 1 Aug, 17:38, "Dave Mennenoh" <d...@blurredistinction.com> (Head
Developer AND Adobe Community Expert) wrote: > Is there a way with PHP to send out a timed, email reminder? For instance, > to send a client an email that their subscription will be expiring in a > week - or to send an email a day before an appointment is due. I can see how > to do if someone logs in and then I run a appointment checker script - but > how to do as a service, or daemon, so it works anytime? > Like the other guys said, cron is the prefered way to do this. And you should implement it is as CLI PHP parsed script outside the webserver document root. If this is not possible becuase you've got a really cheap hosting service you could tie it to your web requests in a common include: <?php if (rand(80)>75) { // tune according to your traffic levels/required granularity if (filemtime($path_to_touch_file) && !file_exists($lockfile)) { file_put_contents($lockfile, getmypid()); $qry="SELECT * FROM scheduled_jobs WHERE due<=NOW()"; // (of course you don't need to store the jobs in a database) .... $qry="UPDATE scheduled_jobs SET due=due+repeat_interval WHERE id= $job_id"; .... unlink($lockfile); file_put_contents($path_to_touch, getmypid()); } } ?> HTH C. |
|
![]() |
| Outils de la discussion | |
|
|