no error message, but it doesnt send an email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wright67uk
Forum Newbie
Posts: 7
Joined: Fri Jan 01, 2010 4:09 pm

no error message, but it doesnt send an email

Post 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.";
?>
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

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

Post by Peter Kelly »

You havent set your headers correctly read http://www.php.net/mail
Post Reply