Hello. I’m trying to send emails with the php mail function, but even though the function evaluates to true int he if statement, the emails never arrive. Below is the code for the form that receives the user input. I’ve changed my email address for privacy reasons:
<?php //start building the mail string $msg = "Name: ".$_POST['name']."\n"; $msg .= "E-Mail: ".$_POST['email']."\n"; $msg .= "Message: ".$_POST['message']."\n"; //set up the mail $recipient = "[email protected]"; $subject = "Form Submission Results"; $mailheaders = "From: My Web Site " . $email . "\n"; $mailheaders .= "Reply-To: ".$_POST['email']; //send the mail if(mail($recipient, $subject, $msg, $mailheaders)){ echo "The email was sent";} ?> Sending mail from the form in Listing 11.10Thanks, <?php echo $_POST['name']; ?>, for your message.
Your e-mail address: <?php echo $_POST['email']; ?>
Your message:
<?php echo $_POST['message']; ?>