Help with Contact Code

I have made a contact form and should send it. I cannot see why it doesn’t send it. The email address is right, i have tried 3 times and looked in junk/inbox and waited a while. But I don’t receive anything.
[php]

Contact Us <? if(isset($_POST['submit'])) { $to = "EDITED OUT"; $subject = $_POST['subject']; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_fieldn E-Mail: $email_fieldn"; echo "Data has been submitted to $to!"; mail($to, $subject, $message, $body); } else { ?> Name:

Email:
Subject:

Message:

<?

}
?>

[/php]

Note: I get a message after submiting it saying Data has been submitted to EDITED OUT!

What’s the return value for the mail() function? Does it return false?

No nothing comes back but “the data has been submitted to **************”

Does a mail account need to be set up that sends the email? I have no idea.

I certainly hope you’ve installed a mail program that handles the mail after PHP has spat it out through the mail() function (and no, Outlook is not suited for that). Try the following:

[php]
if (!mail($yourmail)) {
echo “Mail was NOT sent!”;
}
[/php]

Warning: mail() expects at least 3 parameters, 1 given in /home/www/**************/contact.php on line 32
Mail was NOT sent!

is what i got.

I havent set up a mail program. I thought it was quite strange that it sent without anything sending it :lol:

Can you tell me how to do this or a tutorial on how to do it?

Nope, but Google can help you with tutorials. And that code wasn’t copy-paste-worthy. It was just to illustrate how to use the mail() function inside an if statement to validate its return value.

Sponsor our Newsletter | Privacy Policy | Terms of Service