PHP email headers not coming through

Status
Not open for further replies.

dstestin

New Member
Messages
1
Reaction score
0
Points
1
Here is my email

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
$to = 'my@email.com';
$subject = "New Updates Subscription";
$body = 'Inform ' .$email. ' when website is complete.';
$headers .= "reply-to: " .$email. "\r\n";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers = "Content-type:text/html;charset=UTF-8" . "\r\n";

if (mail($to, $subject, $body, $headers)){
http_response_code(200);
echo 'success';

}
else{
echo 'error';
}
}

the only thing I get is From, Subject, an To. I need the Reply-To so I can reply to the persons email not .x10hosting server.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
If that's a copy-paste of your actual code, take a look at your $headers = ... assignment lines. You're replacing the value, not adding to it. Use = for the first entry, then .= or $headers = $headers. (that version is more typing, but harder to misread) for all subsequent entries.
 
Status
Not open for further replies.
Top