You are here: Re: Email reminders? « PHP Language « IT news, forums, messages
Re: Email reminders?

Posted by C. on 08/02/07 11:40

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация