954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Automatic email

Id like to generate an automatic email at certain times of the week from my website to certain users. i.e at 12.30 on wednesday id like an email reminder sent to user [EMAIL="example@example.com"]example@example.com[/EMAIL]. Can anyone point me in the right direction :?:

solomonski
Newbie Poster
24 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

you need to set up a cron job (or crontab), make sure your webserver allows you to run a cron job, if so look in your control panel for how to set it up, if it's not in there then log in via SSH and type "man cron" to get the man pages. Crons can be difficult to set up so try searching the web for some tutorials or asking in the linux forums for how to set up this particular cron job

Id like to generate an automatic email at certain times of the week from my website to certain users. i.e at 12.30 on wednesday id like an email reminder sent to user [EMAIL="example@example.com"]example@example.com[/EMAIL]. Can anyone point me in the right direction :?:
paradox814
Posting Whiz
351 posts since Oct 2004
Reputation Points: 13
Solved Threads: 4
 

Sorry i didnt mention that the website sits on a windows platform machine.

solomonski
Newbie Poster
24 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 
Sorry i didnt mention that the website sits on a windows platform machine.

The windows scheduled tasks manager works the same as cron. You can set up the task to run your php script.

If you want a purely web based solution take a look at this article in my blog: http://fijiwebdesign.com/content/view/86/77/

You could use the method mentioned there, with a bit of php like:

pseudo code:

[PHP]$query = "select from my_tasks where time < time() and complete = false".
$uncomplete_tasks = query($query);

foreach ( $uncomplete_tasks as $task) {

// carry out task
// for example if you list php scripts to run.. do something like
exec("wget http://example.com/$task.php");
// then update the database, task success, or fail etc.

}[/PHP]

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Many thanks for that

solomonski
Newbie Poster
24 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

I checked out your exec and html solutions, but neither one fit my needs.
I want to implement a distributed script that will send a BirthDay Greeting, automatically, at specific times of the day (midnight, of course). As described here, basically, this is the definition of a cronjob. But you can't distribute a software that will automatically setup a cronjob for the enduser's website, so it's out of discution.
Of course, it can be purely programmed in php/mysql/javascript, if we'd be sure there would be at least one visitor on a specific page that, by loading, would trigger the script for sending the email/emails at that moment in time.
Unfortunatelly, this is only a matter of pure luck!

I would consider the worst case, no one is visiting the website for one entire week (hypothetically).

How can we tell the website hosting server to run a script, as the cronjobs do, without using the cron system?

Is there any alternative to that? (javascript was the first thing that came to my mind, being a server-side language, but i'm not so sure it would work without a client browser triggering...)

What are your ideas/expertise about this? Could it be done? (on any linux/mac/windows servers, of course).
Thanks for your tutorials.

ciprianmp
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

If you don't have cron, then you need a client process to trigger.
You could have a php / javascript reloading page which at a certain time processes the list. You would need a browser running somewhere. This is not necessarily a bad thing as it could act as a status page too.
If you are interested in pursuing this further, I'd be happy to assist you.
regards

marknhopgood
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

I'm not sure if this would work, but try

<?php

$now = time();
$original_tz = $_ENV["TZ"];

putenv("TZ=US/eastern");
if (Date("h:m", $now) == 12:30); 
{
mail(me@example.com, "subject", "MESSAGE");
}

?>
calebcook
Junior Poster in Training
66 posts since Jun 2011
Reputation Points: 10
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You