siral3x Posted May 22, 2007 Share Posted May 22, 2007 I don't receive any errors, but it won't send me the email...I don't know what else to do I have the actual form in 1 file and the processor in a 2nd file with the code as follows: form.html : <form action="process.php" method="post"> <table border=1> <tr> <tr> <td>First name:</td> <td align="center"><input type="text" name="name" size="15" maxlength="30"></td> </tr> <tr> <td>Last name:</td> <td align="center"><input type="text" name="last_name" size="15" maxlength="30"></td> </tr> <tr> <td>Address:</td> <td align="center"><input type="text" name="address" size="15" maxlength="30"></td> </tr> <tr> <td>City:</td> <td align="center"><input type="text" name="city" size="15" maxlength="30"></td> </tr> <tr> <td>State:</td> <td align="center"><input type="text" name="state" size="15" maxlength="30"></td> </tr> <tr> <td>Postal Code:</td> <td align="center"><input type="text" name="zip" size="15" maxlength="30"></td> </tr> <tr> <td>Country:</td> <td align="center"><input type="text" name="country" size="15" maxlength="30"></td> </tr> <tr> <td>E-mail:</td> <td align="center"><input type="text" name="mail" size="15" maxlength="30"></td> </tr> <tr> <td>Telephone:</td> <td align="center"><input type="text" name="tel" size="15" maxlength="30"></td> </tr> </table> <div align="center"><center><table border="0" width="480"> <tr> <td align="center"><input type="submit" value="Submit Order"></td> <td align="center"><input type="reset" value="Reset form"></td> </tr> </table> </center></div> and then process.php: <?php $to = "xxx@yahoo.com"; $subject = "Put your subject line here"; $tmp = array(); foreach($_POST as $fld => $val) if ($fld != 'submit') $tmp[] = $fld . ': ' . stripslashes($val); $body = implode("\are\n",$tmp) . "\are\n"; $headers = 'From: ' . $_POST['name'] . ' <' . $_POST['mail'] . '>'; mail($to,$subject,$body,$headers); echo "<h5>YOUR REQUEST HAS BEEN SENT! WE WILL GET BACK TO YOU SOON!</h5>"; ?> Like I said I receive no errors but it won't send me the email!!! Any solutions?? thx in advance ALEX Quote Link to comment https://forums.phpfreaks.com/topic/52477-php-email-form-doesnt-work-what-is-wrongneed-help-badd/ Share on other sites More sharing options...
hitman6003 Posted May 22, 2007 Share Posted May 22, 2007 As you can see here, http://us.php.net/manual/en/function.mail.php#id4752425, headers need to be separated by "\r\n"...including the last one. WTF is "\are"? I know it's not always necessary to use the curly braces ( {} ), however, since your script isn't functioning properly, you should make sure to use them to eliminate that as a source of error. Ensure error reporting and display errors are turned on: ini_set("display_errors", 1); error_reporting(E_ALL ^ E_NOTICE); <?php ini_set("display_errors", 1); error_reporting(E_ALL ^ E_NOTICE); $to = "xxx@yahoo.com"; $subject = "Put your subject line here"; $tmp = array(); foreach($_POST as $fld => $val) { if ($fld != 'submit') { $tmp[] = $fld . ': ' . stripslashes($val); } } $body = implode("\r\n",$tmp) . "\r\n"; $headers = 'From: ' . $_POST['name'] . ' <' . $_POST['mail'] . '>' . "\r\n"; if (mail($to,$subject,$body,$headers)) { echo "<h5>YOUR REQUEST HAS BEEN SENT! WE WILL GET BACK TO YOU SOON!</h5>"; } else { echo "An error has occurred"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52477-php-email-form-doesnt-work-what-is-wrongneed-help-badd/#findComment-258936 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.