0

I do not know why it is not sending from "From" Address but from some "?@venuse.srv.wz.cz". I was looking for any solution but i did not find any. Still it sends email from ?@venuse.srv.wz.cz. My code:

<?php

if (isset($_POST['name']) && isset($_POST['email']))
{

$name = $_POST['name'];
$email = $_POST['email'];
$from = $_POST['email'];
$to = 'filda@seznam.cz';
$subject = 'Kontaktní formulář';
$body = '<html>
<body>
<p>Jméno: '.$name.'</p>
<p>Email: '.$email.'</p>
<p>Zpráva:<br/><br/>'.$_POST['comments'].'</p>
</body></html>';

$headers = "From: ".$email."\r\n"; 
$headers = "Reply-To: ".$email."\r\n";
$headers = "MIME-Version: 1.0" . "\r\n";

$headers ="Content-type:text/html;charset=UTF-8" . "\r\n";

$send = mail($to, $subject, $body, $headers);

} 
?>

Please, does anyone know where could be any mistake?

Filda
  • 3
  • 1

1 Answers1

1

You are overriding headers assigning them to the same variable without concatenation. Look at example #5

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0\r\n';
$headers .= 'Content-type: text/html; charset=UTF-8\r\n';

// Additional headers
$headers .= "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";

[EDIT] Then as Pawel Szalucki suggested look at this post.

$send = mail($to, $subject, $body, $headers, "-f $email");
Jack Skeletron
  • 1,048
  • 6
  • 25