Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Help with email script

General discussions related to php

Moderators: macek, egami, gesf

Help with email script

Postby scoobysteve » 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
Steve

<?php
$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
<?php
} else {
?>
<form action="test.php" method="post">
<table width="500" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="100%" class="bodytext">Your name:</td>
<td width="100%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext"> </td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
<?php
};
?>
scoobysteve
New php-forum User
New php-forum User
 
Posts: 15
Joined: Thu May 31, 2012 1:08 am

Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron