shanedunning Posted July 6, 2009 Share Posted July 6, 2009 Hi everyone Im having trouble with a php document of mine. its a contact form driven by PHP, it uses a simple form to send a message to my email inbox. It sends an email, but no message or subject is on the email when its sent to my inbox. I havent set up a mail server, this may be the problem but im not sure. This is the code for the php process <?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "Form Tutorial"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; $header = "from: $name <$mail_from>"; mail($to, $subject, $body); } else { echo "Sorry, message not sent!"; } ?> Link to comment https://forums.phpfreaks.com/topic/164920-mailing-list-help/ Share on other sites More sharing options...
shergold Posted July 6, 2009 Share Posted July 6, 2009 isn't the mail() function meant to be mail($to,$subject,$body,$header); if that isn't it echo the values of your $_POST variables before the email is sent to see if its receiving the data from the form correctly. Good luck Shergold. Link to comment https://forums.phpfreaks.com/topic/164920-mailing-list-help/#findComment-869664 Share on other sites More sharing options...
haku Posted July 6, 2009 Share Posted July 6, 2009 $header is optional in mail(). It could be a few things - are you using a free host? Many of them apparently don't allow for the sending of mail. Are you working on a local installation (i.e. you installed a server on your home computer)? Maybe you don't have a mail server set up. Does the email address exist? Some servers won't send mails from an email address that doesn't exist. Link to comment https://forums.phpfreaks.com/topic/164920-mailing-list-help/#findComment-869708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.