0

I am new to building a website and I am sorry if this question has been asked before. I tried finding an answer but I cant seem to pinpoint an answer for my specific problem. I have created a PHP script for my contact form on my website. I would like to add to this script an auto responder so that people that submit the form receive a confirmation/thank you email. The trouble I am having is finding the right code so that my email address shows-up at the top (the from field) of the auto reply email. At the moment the email address showing at the top (the from field) is some weird address of my web hosting company (iPage) instead of my email address.

Here is the code I am using to generate an auto reply. However, I am wondering, what must I add so that my email shows in the from field of the auto reply email?

/* Prepare autoresponder subject */
$respond_subject = "Email Confirmation";

/* Prepare autoresponder message */
$respond_message =

"Thank you for contacting jadesambrook.com!

We will do our best to answer your email as quickly as possible.

Best regards,

www.jadesambrook.com";

/* Send the message using mail() function */
mail($email, $respond_subject, $respond_message);
Jade
  • 3
  • 4
  • [php contact form reply to sender](http://stackoverflow.com/questions/13949834/php-contact-form-reply-to-sender) – dbank Mar 29 '15 at 22:53
  • [Reply to sender - PHP email](http://stackoverflow.com/questions/17418751/reply-to-sender-php-email) – dbank Mar 29 '15 at 22:55
  • [reply-to address in php contact form](http://stackoverflow.com/questions/19007032/reply-to-address-in-php-contact-form) – dbank Mar 29 '15 at 22:55

1 Answers1

1

You need to set the headers, look at this here:

http://php.net/manual/en/function.mail.php

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
     'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
cnorthfield
  • 3,384
  • 15
  • 22
  • Here is what I needed: $message = "Thank you for your interest. We will get back to you as soon as possible.
    Sincerely,
    (My Name)"; $subject = "Confirmation"; $headers2 = "From: $webMaster\r\n"; $headers2 .= "Content-type: text/html\r\n"; mail($email, $subject, $message, $headers2);
    – Jade Mar 29 '15 at 23:51