Help with email script

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 15
Joined: Thu May 31, 2012 1:08 am

Mon Dec 31, 2012 1:25 am

Hi guys can anyone help with the following. I am trying to add the list of emails from my email field into the forms email recipients using the following. It works to a certain extent but it only adds the last email address in the group. If I use echo $row['contact_email'];
I see all the email addresses that I want to send too but only one gets added.

Any advice would be appreciated, Happy New Year BTW

$con = mysql_connect("IP.IP.IP.IP","web4-steve","letmein");
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db("web4-steve", $con);
$result = mysql_query("SELECT * FROM propertylisting_listings WHERE is_featured='T'AND status ='T'");
while($row = mysql_fetch_array($result))

$xx= $row['contact_email'];

if ($_POST["email"]<>'') {
$BccEmail = $xx;
$EmailSubject = 'Global Email from Highgate Park Website';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br><br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($BccEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
Your message was sent
} else {
<form action="test.php" method="post">
<table width="500" border="0" cellspacing="2" cellpadding="0">
<td width="100%" class="bodytext">Your name:</td>
<td width="100%"><input name="name" type="text" id="name" size="32"></td>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
<td class="bodytext"> </td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>

Post Reply