Hi,
I am attempting to send a HTML email via PHP using coding that i know works. It submits the contents of a form to a DB before emailing the results. Here is the coding...
<?php
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
$var3 =$_POST['var3'];
$var4 = $_POST['var4'];
$var5 = $_POST['var5'];
$var6 = $_POST['var6'];
$var7 = $_POST['var7'];
$var8 = $_POST['var8'];
$to = "email@email";
$from = "test";
$subject = "you have recieved an email from" .$_POST['var3'];
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
$message="
<html>
<body>
<center>
<b>Here is the email you have sent</b> <br>
</center>
<p>it's been sent</p>
</body>
</html>";
mysql_connect("localhost","username","password") or die ('Error: ' . mysql_error());
mysql_select_db ('dbname');
$query="INSERT INTO resultslog(var1, var2, var3, var4, var5, var6, var7, var8) VALUES ('".$var1."','".$var2"','".$var3."','".$var4."','".$var5."','".$var6."','".$var7."','".$var8."')";
mysql_query($query) or die (mysql_error());
if (mail($to,$subject,$message,$headers) ) {
ECHO "Your message has been sent";
}else{
ECHO "The email has failed";
}
?>
When I submit the form I am presented with the "Your message has been sent" text and the data is submitted to the DB but the email is not being sent? Does anyone have any idea why this might not be happening?
Thanks,
JC
I am attempting to send a HTML email via PHP using coding that i know works. It submits the contents of a form to a DB before emailing the results. Here is the coding...
<?php
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
$var3 =$_POST['var3'];
$var4 = $_POST['var4'];
$var5 = $_POST['var5'];
$var6 = $_POST['var6'];
$var7 = $_POST['var7'];
$var8 = $_POST['var8'];
$to = "email@email";
$from = "test";
$subject = "you have recieved an email from" .$_POST['var3'];
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
$message="
<html>
<body>
<center>
<b>Here is the email you have sent</b> <br>
</center>
<p>it's been sent</p>
</body>
</html>";
mysql_connect("localhost","username","password") or die ('Error: ' . mysql_error());
mysql_select_db ('dbname');
$query="INSERT INTO resultslog(var1, var2, var3, var4, var5, var6, var7, var8) VALUES ('".$var1."','".$var2"','".$var3."','".$var4."','".$var5."','".$var6."','".$var7."','".$var8."')";
mysql_query($query) or die (mysql_error());
if (mail($to,$subject,$message,$headers) ) {
ECHO "Your message has been sent";
}else{
ECHO "The email has failed";
}
?>
When I submit the form I am presented with the "Your message has been sent" text and the data is submitted to the DB but the email is not being sent? Does anyone have any idea why this might not be happening?
Thanks,
JC