<?php 
	   $a = '10';
	  
	   
if ($_POST["email"]<>'' && $_POST["val"] == "$a" ) { 
	$ToEmail = 'myemail'; 
	$EmailSubject = 'Site contact form '; 
	$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>";
	$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
	
	mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 

<h1>Your message was sent</h1> 

<?php 
} 
else
{
?> 
<form action="contact.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><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">Validation:</td>
<td>3 + 7 = <input type="text" name="val"  />
</td>
</tr>
<tr>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>

</table>


</form> 
<?php 

}; 
?>

this code worked for bout 2 weeks and now does not send the email? it says the message has been sent but i recieve nothing, i have tried this with a hotmail acount and my email address for my site and nothing is working? any help

Hi, I have the same error in my PHP application, I’ve tried many options, but finally I’ve decided to change the hosting company. By the way you can try to add this code into you page to see if they are errors displaying or not

ini_set('display_errors', 1);

Also try this

If (!mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader)){

Echo”error sending message”;

} else {

echo”message was sent”;

}

this all that we can try, but in my other hosting company all works properly so I will change all there, I think this is the PHP server or version problem or something like this, I don’t think that it is the our code problem.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.