rigbyae Posted March 31, 2010 Share Posted March 31, 2010 Okay, pretty new to PHP here. I can read PHP, and understand most of it, just still running into some "stupid" issues. any help would be appreciated. I've included the code for the script that I"m using, or trying to use... Obviously, I've removed some key factors such as my exact email address and thankyou & error page locations. The script will send an email to me, but the html code will be in the email body, and it won't send the message portion from the form. I've double and triple checked the variable names to the html code for the form itself, and the variables are the same. Any suggestions to what's going wrong? ----------my code---------------- <?php /* Subject and Email Variables */ $emailSubject = 'Website Enquiry'; $webMaster = 'myemail'; /* Gathering Data Variables */ $nameField = $_POST['name']; $emailField = $_POST['email']; $phoneField = $_POST['phone']; $formField = $_POST['form']; $body = <<<EOD <br /><hr><br /> Email: $emailField <br /> Name: $nameField <br /> Phone Number: $phoneField <br /> Message: $formField<br /> EOD; $headers .= "Content-type: text/html\n\n"; if (mail($webMaster, $emailField, $emailSubject, $body, $headers)) {header("Location: http://www.mythankyoupage...etc");} else {header("Location:http://www.myerrorpage...etc");} ?> Quote Link to comment https://forums.phpfreaks.com/topic/197063-sendmail-script-issues/ Share on other sites More sharing options...
ale8oneboy Posted March 31, 2010 Share Posted March 31, 2010 Okay, pretty new to PHP here. I can read PHP, and understand most of it, just still running into some "stupid" issues. any help would be appreciated. I've included the code for the script that I"m using, or trying to use... Obviously, I've removed some key factors such as my exact email address and thankyou & error page locations. The script will send an email to me, but the html code will be in the email body, and it won't send the message portion from the form. I've double and triple checked the variable names to the html code for the form itself, and the variables are the same. Any suggestions to what's going wrong? ----------my code---------------- <?php /* Subject and Email Variables */ $emailSubject = 'Website Enquiry'; $webMaster = 'myemail'; /* Gathering Data Variables */ $nameField = $_POST['name']; $emailField = $_POST['email']; $phoneField = $_POST['phone']; $formField = $_POST['form']; $body = <<<EOD <br /><hr><br /> Email: $emailField <br /> Name: $nameField <br /> Phone Number: $phoneField <br /> Message: $formField<br /> EOD; $headers .= "Content-type: text/html\n\n"; if (mail($webMaster, $emailField, $emailSubject, $body, $headers)) {header("Location: http://www.mythankyoupage...etc");} else {header("Location:http://www.myerrorpage...etc");} ?> Recheck the function definition of mail(). mail ( string $to , string $subject , string $message , string $headers ); Change: mail($webMaster, $emailField, $emailSubject, $body, $headers); To: mail($emailField, $emailSubject, $body, $headers); You can specify the sent from address in $headers. Example: $header = "From: $webMaster\n\n"; $headers .= "Content-type: text/html\n\n"; Hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/197063-sendmail-script-issues/#findComment-1034464 Share on other sites More sharing options...
rigbyae Posted March 31, 2010 Author Share Posted March 31, 2010 Made the suggested changes, still getting the same issues. The email sent to my account via the form looks as this: <br /><hr><br /> Email: [email protected] <br /> Name: myname <br /> Phone Number: 0000101111 <br /> Message: <br /> The redirect to either the Thankyou.html or the Error.html works fine. Looking for help in at the very least getting the message into the email sent, if at all possible getting the html code out of the sent email as well. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/197063-sendmail-script-issues/#findComment-1034512 Share on other sites More sharing options...
oni-kun Posted March 31, 2010 Share Posted March 31, 2010 strip_tags Quote Link to comment https://forums.phpfreaks.com/topic/197063-sendmail-script-issues/#findComment-1034514 Share on other sites More sharing options...
Deoctor Posted March 31, 2010 Share Posted March 31, 2010 add these for the headers.. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; and make sure u have the mime installed in php Quote Link to comment https://forums.phpfreaks.com/topic/197063-sendmail-script-issues/#findComment-1034523 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.