| | |
Using PHP to Send Email to a single DB list member every 24 hrs.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Solved Threads: 0
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 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
[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
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
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Solved Threads: 0
: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:
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
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!
[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!
![]() |
Similar Threads
- send email with attachment (PHP)
- How to send email from flash8..using php or asp (Graphics and Multimedia)
- Newbie php question. how to create a mailing list? (MySQL)
- PHP - subscribers' email (PHP)
- how to hide email recipient list (PHP)
- Please help with email form script (PHP)
Other Threads in the PHP Forum
- Previous Thread: Hi I've been told by my bf that php and mysql are very very powerful tools in the com
- Next Thread: Apache
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web white xml youtube





