PHP mail reply to sender instead of server email -


can point out getting form wrong? instead of being able reply "email" sender server email.

here php code:

<?php     $name = $_post['name'];     $email = $_post['email'];     $message = $_post['message'];     $from = 'from: business.com';      $to = 'anyone@gmail.com';      $subject = 'a new message website business.com';     $human = $_post['human'];     $headers = 'from: info@business.com' . "\r\n" .     'reply-to: ' . $email . "\r\n" .     'x-mailer: php/' . phpversion();      $body = "from: $name\n e-mail: $email\n message:\n $message";      if ($_post['submit']) {     if ($name != '' && $email != '') {         if ($human == '4') {                              if (mail ($to, $subject, $body, $from)) {              echo '<p>your message has been sent!</p>';         } else {              echo '<p>something went wrong, go , try again!</p>';          }      } else if ($_post['submit'] && $human != '4') {         echo '<p>you answered anti-spam question incorrectly!</p>';     }     } else {         echo '<p>you need fill in required fields!!</p>';     } } ?> 

and here html

<form method="post" action="contact.php" target="contactiframe" name="contact">     <label>name</label>     <input name="name" placeholder="type here">     <label>email</label>     <input name="email" type="email" placeholder="type here">     <label>message</label>     <textarea name="message" placeholder="type here"></textarea></br>     <label>*what 2+2? (anti-spam)</label>     <input name="human" placeholder="type here"></br></br>     <input id="submit" name="submit" type="submit" value="submit">     <input type="button" name="reset_form" value="clear" onclick="this.form.reset();"> </form> 

thanks everyone

you mail function not have $headers additional headers. code should be...

 if ($human == '4') {                      if (mail ($to, $subject, $body, $headers)) {         echo '<p>your message has been sent!</p>';     }  } 

ref : php mail function


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -