I am working on a simple contact form and the php script is not sending an email to my email... The script is running succesfully and it produces the HTML output seen in the code below. I am trying to figure it out, yet I just cannot get it to send the email. I have looked at tutorials and appear to have the same exact code as a lot of the tutorials out there. I am using a form to get user's input seen here,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dummy Code - Contact</title>
</head>
<body>
<form action="send_simpleform.php" method="post">
<p>Your name<br />
<input name="sender_name" type="text" size="30" /></p>
<p>Email<br />
<input name="sender_email" type="text" size="30" /></p>
<p>Message<br />
<textarea name="message" cols="30" rows="5"></textarea></p>
<input name="submit" type="submit" value="Submit" />
</form>
</body>
</html>
My PHP script can be seen here as well,
<?php
$msg = "Email sent from www.dummycode.com\n";
$msg .= "Sender's Name:\t $_POST[sender_name]\n";
$msg .= "Sender's E-mail:\t $_POST[sender_email]\n";
$msg .= "Sender's Message:\t $_POST[message]\n";
$to = "[email protected]";
$subject = "DummyCode.com";
$headers = "From: My web site <www.dummycode.com>\n";
$headers .= "Reply to: $_POST[sender_email]\n";
mail($to, $subject, $msg, $headers);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dummy Code Contact Sent</title>
</head>
<body>
<h1>The following email has been sent</h1>
<p>Your Name:<br />
<? echo "$_POST[sender_name]"; ?>
<p>Your Email Adress:<br />
<? echo "$_POST[sender_email]"; ?>
<p>Message:<br />
<? echo "$_POST[message]"; ?>
</p>
</body>
</html>
I know I am pretty knew at this and if this is a stupid error on my part, then I'm sorry. I am pretty dumb. Thanks in advance. Please don't hate.
-Henry
$msg .= "Sender's Name:\t $_POST[sender_name]\n";, you have to use something like this$msg .= "Sender's Name:\t ".$_POST[sender_name]."\n";"Sender's Name:\t {$_POST[sender_name]}\n"mail()anyway, the PEAR classMailis more robust and reliable for this stuff.mail()function is pretty awful. I suggest using a decent library like phpMailer if you want to send mail from a PHP program. It will make your code easier to work with, more reliable, and has many more features.