Closed Thread Icon

Topic awaiting preservation: making PHP send reminders...automatically! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12537" title="Pages that link to Topic awaiting preservation: making PHP send reminders...automatically! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: making PHP send reminders...automatically! <span class="small">(Page 1 of 1)</span>\

 
Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 12-02-2002 07:25

Ok, don't know if this is actually possible or not. I am working on a script that I'd like to have the capability of mailing info (through PHP if at all possible) to a user, reminding them of a particular thing (such as paying a bill before it is due). Can this be done without the prompting of user submitted data and/or triggers. I guess this would be similar to a cron job, but I was wondering if it could be done with PHP without having to do things from a server's command line. Any idears?

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 12-02-2002 08:51

Are you just saying that you what to send someone email using PHP?

If so, yes, you can find out how by going here...
http://www.php.net/manual/en/ref.mail.php


"Can this be done without the prompting of user submitted data and/or triggers" : You will need their email address.

[edit]That's not you what is it. You want the email to be to sent, "automatically". Like configured on a timer/clock/sleep/etc. That my friend is a damn good question; yet I don't know the anwser yet, sorry. I .............[/edit]

..
~Existence is a mere pattern.~

[This message has been edited by Rooster (edited 12-02-2002).]

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-02-2002 09:20

sorry thumper, but you will need a way to periodically call the php page that handles the sending of the mails -> a cron job.
Or possibly call the page yourself ever hour... but that defeat's the purpose.

If you had a well visited site, you could embed the sending in a normal page view, checking the time each time... but it would not be as reliable.

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 12-02-2002 09:48

Well TP, I figured as much... What are the ramifications on running a daily cron job off a secure area (admin area)?

(I have never done one!)

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 12-02-2002 10:30

This is me just being, well, me, but could you somehow write a script that gets called when someone visits a page or numerous pages, preferably pages that get an ample amount of hits. This script would check if reminders needed to be sent out. But you would set the reminder threshold to a smaller amount of time due to that fact that the script will be called often. And because the script gets called often the amount of processing will be very small.

Is this just a very bad idea?


[edit]I guess that would be considered a "trigger", but it seems to me that it would be better than calling the script yourself every hour[/edit]

[edit]And I'm talking about placing a PHP script in pages that are already written in PHP, do you know what I mean?[/edit]


..
~Existence is a mere pattern.~

[This message has been edited by Rooster (edited 12-02-2002).]

[This message has been edited by Rooster (edited 12-02-2002).]

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 12-02-2002 13:12
quote:
Well TP, I figured as much... What are the ramifications on running a daily cron job off a secure area (admin area)?

(I have never done one!)



You're just better off using a cron job. You can use cron to do anything.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-02-2002 17:22

As much as I love php for web development this is the kind of thing I usually do with perl and cronjob.

cron's your best best for any type of timed appliactions.



.:[ Never resist a perfect moment ]:.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-02-2002 19:35

not that there is much difference whether you call a perl script, or a php script via a cron job.

Ok, here are your options:
a) uses Cronjobs to call said script every X hours.
Pro: Pretty reliable. Works wether some one visits the site or not. Doesn't slow things down.
Con: You need cron jobs...

b) Execute the script whenever a user visit's your (a) page.
Pro: Doesn't need cron jobs.
Con: You must have a visitor at least every X hours. Mails might be delayed because no one visited. Mails may be dropped because the user pressed 'stop' in his browser. Slows your page down. (drastically, if you do it wrong ;-))

so long,

Tyberius Prime

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 12-02-2002 22:12

Bitdamaged - You can use PHP with cron as well. That's what we're doing at GN, and what I'm doing at http://www.macombsheriff.com/ for things like the weather, and the upcoming Homeland Defense Security Level.

Cron is quite nice!

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-03-2002 18:31

It's trickier without cron but it could be done with a little perl deamon. Here's a quick hack for running a script once a day.

#!/usr/bin/perl
use strict;
my $eventtime = 8:30;
my $eventname = "/home/mikey/mailscript.pl"
my $TIMEOUT = 60;
while (1) {
my ($min, $hour) = (localtime(time))[1,2];
exec($eventname) if ("$hour:$min" eq $eventtime);
sleep $TIMEOUT;
}

It's an infinite loop that just keeps running. Once a day it should hit and send your mail.



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 12-03-2002).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 12-03-2002 18:44

oh and be careful with that script a Sysadmin might shit if you fark it up



.:[ Never resist a perfect moment ]:.

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 12-04-2002 03:59

Thanks for the advices fellas, and for the code bitdamaged. I know this is something that my lazy ass could just do everyday (I work from home), but I am on this server-side automation kick and thought I'd see how feasible it was.

« BackwardsOnwards »

Show Forum Drop Down Menu