User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,712 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,427 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2752 | Replies: 3
Reply
Join Date: Feb 2006
Posts: 2
Reputation: kentf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kentf kentf is offline Offline
Newbie Poster

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

  #1  
Feb 1st, 2006
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

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

  #2  
Feb 1st, 2006
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]$usersEmails = mysql_query("select emails from table where ...... ");
$message = generateEmailMessage()
while ($row = mysql_fetch_row($usersEmails)) {
mail($row[0], 'Member of the Day', $message);
}[/PHP]

where generateEmailMessage() is the email message

now just have the cron run this script every night around 2:00am or so
Reply With Quote  
Join Date: Feb 2006
Posts: 2
Reputation: kentf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kentf kentf is offline Offline
Newbie Poster

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

  #3  
Feb 6th, 2006
: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:




Originally Posted by paradox814
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]$usersEmails = mysql_query("select emails from table where ...... ");
$message = generateEmailMessage()
while ($row = mysql_fetch_row($usersEmails)) {
mail($row[0], 'Member of the Day', $message);
}[/PHP]

where generateEmailMessage() is the email message

now just have the cron run this script every night around 2:00am or so
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

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

  #4  
Feb 7th, 2006
you need to set the headers....

[php]$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"; [/php]

after doing that, change[php]mail($row[0], 'Member of the Day', $message); [/php] to [php]mail($row[0], 'Member of the Day', $message, $headers); [/php] hope this works!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC