Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Please help me to set up php emails to be sent to different person
Closed Thread
Old 12-14-2007, 06:42 AM   #1 (permalink)
 
Super Techie

Join Date: Feb 2004

Posts: 442

linux1880 is on a distinguished road

Send a message via Yahoo to linux1880
Default Please help me to set up php emails to be sent to different person

<?php
$to = "me@headache.com";
$subject = "hi how are you";
$body = "helllo hello this is test.. this is test ........";
$headers = "From: mail@mail.co.uk\r\n" .
"X-Mailer: xxxx LONDON";
if (mail($to, $subject, $body, $headers)) {
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>


Hello friends,

I want to send this email to different users.
I already have variables like

emails: <?=$row['email_add'] ?>
body: <?=$row['noteforstudents'] ?>

I just want different person to receive email according to the details above. Do I need to set up session or require_once for this ?

I don't know how to setup pls help
linux1880 is offline  
Old 12-15-2007, 03:43 AM   #2 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: Please help me to set up php emails to be sent to different person

When you SELECT your query, use the while loop to send the Email.

Example:
PHP Code:
<?php
$subject 
"hi how are you";
$headers "From: mail@mail.co.uk\r\n" .
"X-Mailer: xxxx LONDON";

$sql "SELECT * FROM mysql_table";
if (
$r mysql_query ($sql)) {
while (
$row mysql_fetch_array ($r)) {
// send the email here...it will send the email to however many people the query returns

mail($row['email_add'], $subject$row['noteforstudents'], $headers);
}
}

?>
Hope that helps.
__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use MS Outlook Contacts track clients emails and clients information? david55 Windows Operating Systems and Software 7 11-12-2007 07:18 AM
Help with downloading emails to outlook 2000 pengyou Browser & General Internet Questions 1 09-04-2007 01:11 PM
Outlook express not deleting some emails off the server Mr. tech Windows Operating Systems and Software 0 07-16-2007 09:30 PM
PHP 2-player game? thejeremy Programming Discussions 4 04-09-2007 06:01 PM
Remote file access w/ IP + PHP? thejeremy Programming Discussions 2 04-04-2007 05:24 PM