reply-to address in php contact form
Try changing this part of your code :
$subject = "Contact Form: $name";
$message = "$message";
$headers = 'From: myemail@my_domain.com' . "\r\n" .
'Reply-To: $email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
To this :
$subject = "Contact Form: $name";
$message = "$message";
$headers = 'From: myemail@my_domain.com' . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
Basically take out the $email from inside the single quote and append it to that string
how to reply to sender email using php contact form
First make headers
$headers = "From: $from\r\nReply-to: $email";
Than fix calling of mail function to be
mail ($to, $subject, $body, $headers)
Didn't tried it from times when it was PHP 4 but it will probably work as you expected...
Addition:
I just checked on php.net... go to this url http://php.net/manual/en/function.mail.php and check "Example #2 Sending mail with extra headers."
Contact Form reply address
Use this:
mail($mailTo, $subject, $message, 'Reply-To: '.$mailFrom);
How can reply-to be added to the email we get from our website PHP form?
Here is the code I used to fix both the DMARC authentication problem and the correct 'reply to' email address coming up in gmail.
<?php
$to = "info@futonz.co.nz";
$name = ($_POST['name']);
$email = ($_POST['email']);
$phone = ($_POST['phone']);
$enquiry = ($_POST['enquiry']);
$where = ($_POST['where']);
$sub = "".$name."'s enquiry from the Futonz Website!";
$headers .= "MIME-Version:1.0\n";
$headers .= "Content-type: text/plain; charset=utf-8\n";
$headers .= "X-Mailer: $DOMAIN\n";
$headers .= "X-MSMail-Priority: normal\n";
$headers .= "Return-Path: ".$email."\r\n";
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-To: ".$email."\r\n";
$mes = "".$sub."\r\n\n";
$mes .= "Name: ".$name."\r\n";
$mes .= "Email: ".$email."\r\n";
$mes .= "Phone: ".$phone."\r\n\n";
$mes .= "Message: ".$enquiry."\r\n\n";
$mes .= "I found Futonz by: ".$where."";
if(empty($name) || empty($email)) {
header("Location:required-fields.html");
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
header("Location:invalid-email.html");
}
else {
mail($to, $sub, $mes, $headers);
header("Location:contact-thanks.html");
exit();
}
?>
Thank you to those who tried to help here :)
This link may be of interest to people trying to fix yahoo DMARC problems:
https://help.yahoo.com/kb/mail/SLN24016.html
Add auto reply to php code for contact form
Just send a second email, one to you with details and one to the sender with auto response message.
//your existing code
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
//add this
$headers = 'From: '.$email_to."\r\n".
'Reply-To: '.$email_to."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_from, "Thanks For reaching Out", "Auto Reply - Do Not Respond", $headers);
PHP (Mail) Contact Form - reply to sender's email issue
Instead using hard-coded "From" you should receive user's email and set it as 'from'.
I guess that in your form you have email field with name email
. So change from
'From: ' . $from,
to
'From: ' . $_POST['email'],
Now header From:
should contain provided user's email. In my opinion your code is weird but this fix your problem.
Related Topics
PHP "Header (Location)" Inside Iframe, to Load in _Top Location
How to Join Three Tables in Codeigniter
How to Add a Condition Inside a PHP Array
How to Have Multiple $_Get with the Same Key, Different Values
Getting All $_Post from Multiple Select Value
Simulate PHP Array Language Construct or Parse with Regexp
Download Multiple Files as a Zip Folder Using PHP
Discount for Certain Category Based on Total Number of Products
How to Insert Multiple Rows in PHP Pdo MySQL
Php: What Is the Complexity [I.E O(1),O(N)] of the Function 'Count'
The Ultimate Emoji Encoding Scheme
How to Render Content from String/Database with Twig
SQL Query with Binary Data (PHP and MySQL)
How to Recursively Obtain the "Parent Id" of Rows in This MySQL Table