On a site I'm building, on the first page there is a "Featured Member Of The Day!" This is set up through a php script to randomly selects a new member business every 24 hours from the MySQL DB... We've got this all working with the MySQL DB and the tables we've set up. Here's my problem or question......

I would like to automatically have the same "featured Business of the day" notified by an email that they are that day's featured business! This needs to be automatic and happen at the start of each day exactly when they are made that day's featured business!...

Though I have been told that this can be "easily" done, I have not been able to find anything or scripts that would enable this. Any Help there???

Some sites are suggesting "CRON" and say it's installed on most Linux servers, and my host server has a version of that, but I am still at a loss for the php script.

I have missed my deadline for this client for yesterday already... So any help or direction you could point me in would be greatly appreciated!!!!!

Please send your reply to my email address link.

Thanks,
Kent
:?:

I don't understand what your question is, do you not know how to randomly select a user from the database? do you not know how to send an email from the script? If you know how to do that then that should be all you need to do

here is some skeleton code to get you started

$usersEmails = mysql_query("select emails from table where ...... ");
$message = generateEmailMessage()
while ($row = mysql_fetch_row($usersEmails)) {
    mail($row[0], 'Member of the Day', $message);
}

where generateEmailMessage() is the email message

now just have the cron run this script every night around 2:00am or so

:cry: Hi,
You quickly gave me a answer... but I got the randomizer working... The problem is that even after using yours or other suggested scripts... the message received by the "recipient" comes from the "root server address". I want to be able to customize this.

Even after doing the following script... I get the same result!
<?php
$to = "jason@example.com";
$from = "support@example.com";
$title = "Support subscription confirmation";
$body = <<< emailbody
Dear subscriber,

This email confirms your purchase of a 30 day
email support subscription. Please direct all
requests to support@example.com.

Any ideas????

Kentf
kent@via-media.com

paradox814

Junior Poster

Join Date: Oct 2004

Location: San Francisco, CA

Posts: 241

Rep Power:

Re: Using PHP to Send Email to a single DB list member every 24 hrs.

Feb 1st 2006, 08:59 PM | #2

I don't understand what your question is, do you not know how to randomly select a user from the database? do you not know how to send an email from the script? If you know how to do that then that should be all you need to do

here is some skeleton code to get you started

PHP Code:

$usersEmails = mysql_query("select emails from table where ...... ");
$message = generateEmailMessage()
while ($row = mysql_fetch_row($usersEmails)) {
mail($row[0], 'Member of the Day', $message);
}

where generateEmailMessage() is the email message

now just have the cron run this script every night around 2:00am or so :cry:

I don't understand what your question is, do you not know how to randomly select a user from the database? do you not know how to send an email from the script? If you know how to do that then that should be all you need to do

here is some skeleton code to get you started

$usersEmails = mysql_query("select emails from table where ...... ");
$message = generateEmailMessage()
while ($row = mysql_fetch_row($usersEmails)) {
    mail($row[0], 'Member of the Day', $message);
}

where generateEmailMessage() is the email message

now just have the cron run this script every night around 2:00am or so

you need to set the headers....

$sender_name = "Your Email Name";
$sender_email = "Your Email Address";
$headers .= "From: ".$sender_name." <".$sender_email.">\r\n";
$headers .= "Reply-To: <".$sender_email.">\r\n";
$headers .= "Return-Path: <".$sender_email.">\r\n";

after doing that, change

mail($row[0], 'Member of the Day', $message);

to

mail($row[0], 'Member of the Day', $message, $headers);

hope this works!

hi i want to know that how in 24 hour period a particular function can be executed automatically while a application is running on server

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.