Originally Posted by
dawid17
Code:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mailTo = "MYMAIL@hotmail.com";
$headers = "From: ".$email;
$txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
mail($mailTo, $name, $txt);
header("Location: mailsend.php");
}
How can I make this email to appear on the top instead of my servers email address?
The $headers doesnt seem to work?
whenever I change the code to mail($mailTo, $name, $txt, $headers); I do not receive any email at all.
Mail does have a 5th parameter that you can add. I think you can force the mail from address, like I have done below. But, it possibly could be how your mail server is setup that is causing the issue. You can also pass an array to the 4th parameter btw.
Code:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mailTo = "MYMAIL@hotmail.com";
$headers = array(
'From' => $email,
'Reply-To' => $email
);
$params = "-f ".$email;
$txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
mail($mailTo, $name, $txt, $headers, $params);
header("Location: mailsend.php");
}