-
May 15th, 2007, 08:23 AM
#1
Automatically sends (server)
Hi. I have a system where I add emails and birthday dates.
Today, when it is someone´s birthday I log in the system and
manually send all greeting emails.
I was wondering If somehow my system at the server could
run by itself and identify that today is day X and that Y users are
celebrating their birthday so the system should AUTOMATICALLY sends
all the greeting emails WITHOUT me having to log in and pushing any button.
Is that possible?? How can I do that?
Thanks
-
May 15th, 2007, 08:39 AM
#2
Re: Automatically sends (server)
If you use a linux server you can use crontab for this
check-out this tutorial
http://www.sitepoint.com/article/introducing-cron
-
May 15th, 2007, 05:33 PM
#3
Re: Automatically sends (server)
I do use a linux-server but to do that I´d still need to set a cron MANUALLY at my server´s cpanel which I can´t.
How can I do that using a php script to set a cron?
-
May 16th, 2007, 10:43 AM
#4
Re: Automatically sends (server)
Do you not have access to cpanel? PHP can't set up a cron on a server.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 16th, 2007, 11:34 AM
#5
Re: Automatically sends (server)
I do have cpanel but I cant set up a cron manually
I need somehow to do that using a php script.
Any other solutions?
-
May 16th, 2007, 01:05 PM
#6
Re: Automatically sends (server)
I think you misunderstand what a cron is. A cron is simply a scheduled task. Basically, the cron tells the kernel to execute whatever you have set the cron to execute at the time you have set it. PHP is something that can be set by a cron but PHP cannot create a cron.
Please explain why you can't set the cron manually. You only have to set it once and then the cron executes as you have preset the time.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 17th, 2007, 10:55 AM
#7
Re: Automatically sends (server)
I think you didnt understand me.
I need to run a script automatically but I can never set it to run by myself.
It needs to run by itself.
Lets say I need to email you everyday.
I know I can set a cron to do that.
What I need is that at the moment you register for example it automatically creates something to send you a message automatically every day.
How can I do that?
-
May 17th, 2007, 11:27 AM
#8
Re: Automatically sends (server)
I'm sorry, but I think you are the one mistaken.
You set a cron. That cron makes the PHP run automatically. You can set the cron once and never have to touch it again. That means it is automatic. How does this not solve your problem?????
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 18th, 2007, 02:57 PM
#9
Re: Automatically sends (server)
Originally Posted by PeejAvery
I'm sorry, but I think you are the one mistaken.
You set a cron. That cron makes the PHP run automatically. You can set the cron once and never have to touch it again. That means it is automatic. How does this not solve your problem?????
i CAN NOT set a cron myself.
It has to be set without me even getting close to that.
Imagine this:
You know that
- clientA needs to send 2 emails every day
- clientB needs to send 5 emails every weekend
- clientC needs to send 12 emails every monday
If I would do what you said I would have to go to my cpanel and set the cron so it would send the emails automatically. I understand that
The problem is that I dont want to do that
I´d like for example that when ClientA, B, C uses my system to choose how many emails he would like to send and when then what I need would be done somehow with a script
Understand now?
-
May 18th, 2007, 04:28 PM
#10
Re: Automatically sends (server)
Originally Posted by rogernem
Understand now?
Now that you have clearly explained, yes, I do.
Well, the only way that PHP could set a CRON would be to send it to the kernel. Have you tried any of the following to send a linux command line?
system
exec
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 21st, 2007, 12:23 PM
#11
Re: Automatically sends (server)
Nope, never have?
Any idea on how I could do that?
-
May 21st, 2007, 01:59 PM
#12
Re: Automatically sends (server)
Well, you would have to figure out how to create a cron through the command line within Linux. Those PHP commands send to the command line.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 22nd, 2007, 07:45 AM
#13
Re: Automatically sends (server)
another way is to create a php shell script with the CLI installed/enable on the PHP configuration. again, the script should be ran only once upon system start up via cron, or let say manually using the command line.
the main body of the script may be a message loop/pump which may contain one or more procedures that you want to include, one of them of course is your email function. using the IPC mechanism your php web page can send send-email message to the loop.
Code:
// perhaps, initialize a semaphore IPC object here
// initialize message queue IPC object here
// perhaps initialize some shared mem IPC object here
// set process control handler
declare(ticks=1);
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");
.
.
etc
// message loop
do {
if (msg_receive($msg_id, $i, $msg_type, 16384, $msg, true, MSG_IPC_NOWAIT, $msg_err)) {
switch ($msg['id']) {
case SEND_EMAIL_MSG:
my_send_email_function($msg['parameter']);
break;
}
}
} while (true);
// process control handler
function sig_handler($signo) {
switch ($signo) {
case SIG_TERM:
case SIG_INT:
// clean up routine
break;
.
.
.
etc
}
}
unfortunately, the Semaphore, Shared Memory and IPC Functions plus the Process Control Function must be enabled/present on your PHP configuration/installation otherwise it will not work. you may check the PHP manual for more info on the funcs/libs.
just an idea
Busy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|