Jump to content

mailing list help


shanedunning

Recommended Posts

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.