joshgarrod Posted March 27, 2008 Share Posted March 27, 2008 Hello all, I have a PHP form but it doesn't seem to work. Everything looks right to me and when you submit the it goes to my success page, but I receive no email in my inbox. any ideas please? PHP: <?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "[email protected]"; $Subject = "subject line"; $Name = Trim(stripslashes($_POST['Name'])); $Articletitle = Trim(stripslashes($_POST['Articletitle'])); $Articletext = Trim(stripslashes($_POST['Articletext'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Article title: "; $Body .= $Articletitle; $Body .= "\n"; $Body .= "Article text: "; $Body .= $Articletext; $Body .= "\n"; $Body .= "Email from: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "blah blah"; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">"; } ?> HTML: <form method="POST" action="contact.php"> Fields marked (*) are required <p>Email From:* <br> <input type="text" name="EmailFrom"> <p>Name:*<br> <input type="text" name="Name"> <p>Article title:*<br> <input type="text" name="Articletitle"> <p>Article text:*<br> <textarea name="Articletext" cols="100" rows="20"></textarea> <p><input type="submit" name="submit" value="Submit"> </form> Link to comment https://forums.phpfreaks.com/topic/98245-my-php-form-doesnt-work/ Share on other sites More sharing options...
cooldude832 Posted March 27, 2008 Share Posted March 27, 2008 your email probably is lacking proper headers thus its getting bounced Link to comment https://forums.phpfreaks.com/topic/98245-my-php-form-doesnt-work/#findComment-502683 Share on other sites More sharing options...
joshgarrod Posted March 27, 2008 Author Share Posted March 27, 2008 So how do I stop that from happening? Link to comment https://forums.phpfreaks.com/topic/98245-my-php-form-doesnt-work/#findComment-502685 Share on other sites More sharing options...
asaschool Posted March 28, 2008 Share Posted March 28, 2008 try using these headers for your mail function: $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; $headers .= "From: NAME <" . $toOne . ">\r\n"; mail($to, $subject, $body, $headers); You will have better success using headers to achieve what you want Link to comment https://forums.phpfreaks.com/topic/98245-my-php-form-doesnt-work/#findComment-502710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.