Page 1 of 1

how to use send mail when an event occurs

Posted: Sat May 07, 2005 2:14 am
by itsmani1
i want to use send mail function of php on some event like new year etc. (i want to send email on 1st jan how to do that) i have problem in mail funciton and its use but how to intigrate it with time/event.

Posted: Sat May 07, 2005 7:05 am
by timvw
1-) write a script that sends the emails.. (don't care about timing or things like that)

2-) if you are on a linux machine, lookup the "at" command. or "cron(tab)". on a windows machine you need the "task scheduler?". And schedule the script to run at newyear ;)

Posted: Tue May 17, 2005 7:31 am
by itsmani1
are you sure in this way i will be able to handel my alerts. actually my requirements are:
some one add or delete on the system, now what i want is : if the alert is present on the system and its time of execuation has come it has to be executed and i did not found any thing available in php for tht till now.

Posted: Tue May 17, 2005 3:01 pm
by hongco
itsmani1 wrote:... i did not found any thing available in php for tht till now.
to make it simple, like Tim said, use crontab. Have your alert script executed once a day. It searches on database for event.. Each event has date entered into the database. If the date matched with today's date -> send email.

If you are advanced, instead of running the script everyday and search the whole table on datbase looking for today's event, you can write script to add to crontab for every single event. PHP only cannot write to cronjob log if it does not allow to use shell command, but you can use PHP and include cgi using virtual function. The rest on how to write to the log - I don't know how :)

Posted: Tue May 17, 2005 4:02 pm
by timvw
the easiest is to generate a file with all the jobs in...
and then `crontab $nameoffile`; to load all the jobs..