I have a problem using the PHP mail function using a very simple form. I have been uploading the files to our webserver and the form works fine and redirects to the correct page, however, the test email I send never arrives. Can anyone help with this?

//This is the form send_mail.php
<form method="post" action="sendmail.php">
  Email: <input name="email" type="text" /><br />
  Message:<br />
  <textarea name="message" rows="15" cols="40">
  </textarea><br />
  <input type="submit" />
</form>
//This is the sendmail.php
<?php
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "seanlubbe@gmail.com", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: http://www.lfmi.org/html/thanks.php" );
?>
Member Avatar for langsor

I don't know what the problem was ...

This works

<?php
  $recipient = 'seanlubbe@gmail.com'; // used my email for testing ...
  $subject = 'Feedback Form Results';
  $message = $_REQUEST['message'];
  $headers .= 'From: '.$_REQUEST['email']."\r\n";

  mail( $recipient, $subject, $message, $headers ) 
    or die( "Failed to send email" );
  // should use
  // if ( $_REQUEST['email'] ) {
  // for this next line
  header( "Location: http://www.lfmi.org/html/thanks.php" );
?>
<html>
<head>
</head>
<body>
<form method="post" action="<? $_ENV['SELF'] ?>">
  Email: <input name="email" type="text" /><br />
  Message:<br />
  <textarea name="message" rows="15" cols="40"></textarea><br />
  <input type="submit" />
</form>
</body>
</html>

Hope it helps

Solved! Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.