i have a script to send mail using php... the form send the emails fine but th from part of the form doesn't seem to work... tried loads of variations but no joy... can you help!? THE FORM: <form action="process.php" method="post" /> <label for="Name">Name:</label> <input type="text" name="Name" id="Name" size="50" /> <label for="Number">Telephone:</label> <input type="text" name="Number" id="Number" size="50" /> <label for="Email">Email:</label> <input type="text" name="Email" id="Email" size="50" /> <label for="Enquiry">Enquiry:</label> <textarea name="Enquiry" id="Enquiry" rows="4" cols="50" ></textarea> <input name="submit" class="button" id="submit" type="submit" value="Send Enquiry" /> HTML: THE PROCESS: <?php $EmailTo = "email@website.com"; $Subject = "Website Enquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Number = Trim(stripslashes($_POST['Number'])); $Email = Trim(stripslashes($_POST['Email'])); $Enquiry = Trim(stripslashes($_POST['Enquiry'])); $Headers = "From: $Email" . "\r\n"; $Headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $Headers .= "MIME-Version: 1.0" . "\r\n"; // validation $validationOK=true; if (Trim($Name)=="") $validationOK=false; if (Trim($Number)=="") $validationOK=false; if (Trim($Email)=="") $validationOK=false; if (Trim($Enquiry)=="") $validationOK=false; if (!$validationOK) { echo "<h2>Oops...</h2><p>An error occurred and the message could not be sent, please try again...<br /><br />"; echo "<br /><a href=\"javascript:history.go(-1);\">« Go Back</a></p>"; } else { // email body $Body = "<html>" . "\r\n"; $Body .= "<body>" . "\r\n"; $Body .= "<br />"; $Body .= $Subject; $Body .= "<br /><br />Name: "; $Body .= $Name; $Body .= "<br /><br />Telephone Number: "; $Body .= $Number; $Body .= "<br /><br />Email: "; $Body .= $Email; $Body .= "<br /><br />Enquiry: "; $Body .= $Enquiry; $Body .= "</body>" . "\n"; $Body .= "</html>"; $success = mail($EmailTo, $Subject, $Body, $Headers); echo " <h2>Thanks ".$Name."!</h2><p>Your message has been sent successfully.<br /><br />We will respond as soon as possible.</p> \n"; } ?> PHP:
Try changing this line $success = mail($EmailTo, $Subject, $Body, $Headers); Code (markup): to $success = mail($EmailTo, $Headers, $Subject, $Body); Code (markup):
organic cyborg, why would you think that changing the order of the parameters (to an incorrect one) would solve this issue? Does $success equal true or false? Also display your errors, add this at the top: error_reporting(E_ALL); ini_set('display_errors', 1); PHP: If the email is being sent, it should be correct because mail will not be sent without a from header:
Heh, it looked out of order, being send to mail() towards the end. I'm not sure why I thought it was causing the problem. I tested the code and it worked fine for me.