Question:
contact php form problem?
?
2010-10-17 20:07:41 UTC

$mailTo = "myemail@gmail.com";
$mailFrom = $_POST['emailFrom'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = "From:" . $_POST['name'];
header("Location: index.html#contact");

mail($mailTo, $subject, $message, $mailFrom, $headers);

?>

this is the code I used for my contact it doesn't seem to work did I do some ting wrong
Four answers:
anonymous
2010-10-17 21:04:04 UTC
Your current hosting package MUST allow SMTP ( http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol ) to work. Otherwise, no email can be sent.



PHP: Sending Email Tutorial (Text/HTML/Attachments): http://www.webcheatsheet.com/php/send_email_text_html_attachment.php



Use any of the below sites to make the workable form you need:



For making forms:



These are really good online form makers. Just follow the instructions for making it and uploading file(s).



Contact Form Generator: http://www.tele-pro.co.uk/scripts/contact_form/

WYSIWYG Form Maker: http://www.jotform.com/?gclid=CNKhqei1wJ4CFRQhnAod6laUqA

http://www.thesitewizard.com/wizards/feedbackform.shtml

Ajax - Creating an HTML Form: http://www.tizag.com/ajaxTutorial/ajaxform.php

http://www.phpform.org/



http://www.thepcmanwebsite.com/form_mail.shtml

http://emailmeform.com/

http://www.freecontactform.com/





Ron
Robin T
2010-10-18 20:57:37 UTC
The fourth parameter is supposed to be the header. There's no parameter for the 'mail from'. You have to include it in your mail header. And in your header, the from part should have a valid email address, not just the name.



Look at Example #2 here: http://php.net/manual/en/function.mail.php
[ J ] a [ Y ]
2010-10-17 20:11:09 UTC
You're redirecting the user before the mail(...) function is called.



Place the header(...) function call at the end of your script, after the mail(...) function. Just remember not to output anything before the header(...) function, or it won't work correctly.
Bluebell
2010-10-17 20:35:04 UTC
Basic Email function in PHP




$subject='This is a sample mail.'; // Subject of your email

$to='test@test.com'; //Recipient Email

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= "From:Company Name <'admin@test.com'>" . "\r\n"; // Sender's Email

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$message='Content of the mail';

mail($to, $subject, $message, $headers);

header ("Location:yourpage.html");

exit;

?>


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...