Page 1 of 1

no error message, but it doesnt send an email

Posted: Thu Feb 10, 2011 12:00 am
by wright67uk
I am trying to put together some php code, but it doesnt send my emails, can you help?
Im a newbie at php and im trying to get a script to work.
Can you see what im doing wrong. I recieve no error codes, however no email gets sent.
The html content returns fine.

Im trying to pull 3 emails from my database, based on their postcodes, and then send each of these email addresses a message.

Code: Select all

$code = $_GET['postcode'];
$message = $_GET['message'];
$shortcode = substr($code,0,2);
$result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3")
or die(mysql_error()); 
echo "<h2>Business Names:</h2>"; 
while ($row = mysql_fetch_array( $result )) 
{
$message .= "\r\n". $row['email'] ;
}
$i = 0;
while($row = mysql_fetch_assoc($result)) {$value[] = $row['email'];}
{
$i++;
switch($i)
{
case 0:$value1 = $row['email'];
break;
case 1:$value2 =$row['email']; 
break;
case 2:$value3 =$row['email'];
break;
}}
$emailad = "$value1, $value2, $value3";
echo nl2br ($message); 
mail( "$emailad", "Header","$message" );
echo "<br>" . "Thank you for using our mail form.";
?>

Re: no error message, but it doesnt send an email

Posted: Thu Feb 10, 2011 2:47 am
by Peter Kelly
You havent set your headers correctly read http://www.php.net/mail