mattrd Posted August 19, 2011 Share Posted August 19, 2011 I can't seem to get my email form to work. yet it seems to work "sometimes" but not sure why, now i can't seem to get it to work at all. here is my code. <?php $title="Contact Me"; ?> <?php include("includes/header.php"); ?> <?php if ($_POST["email"]<>'') { $ToEmail = 'MY-EMAIL-GOES-HERE; $EmailSubject = 'Website Contact Form'; $mailheader = "From: ".$_POST["name"]."\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["comments"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> <div id="content"> <h1>Contact.</h1> Your message was sent. <?php } else { echo "<div id=\"content\"> <h1>Contact.</h1> <p>Please use the form below to send me an email. I'd love to hear from you!</p> <form action=\"contact.php\" method=\"post\"> <label>Name:</label><br /> <input class=\"text\" type=\"text\" name=\"name\" /><br /> <label>Email Address:</label><br /> <input class=\"text\" type=\"text\" name=\"email\" /><br /> <label>Comments:</label><br /> <textarea name=\"comments\" cols=\"60\" rows=\"5\" name=\"comments\"></textarea> <br /> <input type=\"submit\" value=\"Submit\" /> </form>;" ?> </div> <?php }; ?> <?php include("includes/footer.php"); ?> Any help will be greatly appreciated. (form can be viewed here:) http://www.matthewrdaniels.com/contact.php Thank you! Link to comment https://forums.phpfreaks.com/topic/245209-php-email-form/ Share on other sites More sharing options...
mattrd Posted August 19, 2011 Author Share Posted August 19, 2011 Okay, I found out that most of the emails were going to my junk mail filter. But some didn't. Also, most of the emails show up under the name "Unknown Sender" while others show the name that was put into the name field. Any idea what could be causing that? Link to comment https://forums.phpfreaks.com/topic/245209-php-email-form/#findComment-1259444 Share on other sites More sharing options...
esoteric Posted August 19, 2011 Share Posted August 19, 2011 $yourname = "name"; $youremail = "[email protected]"; $subject = "you subject title"; $body = "message you want to send" $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers = "From: $yourname<$youremail>\r\n"; $headers .= "X-Mailer: PHP's mail() Function\n"; mail($to, $subject, $body, $headers); Try this Link to comment https://forums.phpfreaks.com/topic/245209-php-email-form/#findComment-1259448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.