“来自”和“回复”不能在我的PHP联系表单中使用

时间:2015-02-24 14:57:33

标签: php html contact

我设置了一个简单的php联系表单。它到目前为止工作,我收到电子邮件,这不是问题。唯一不起作用的是“发件人”和“回复”字段。我收到的电子邮件来自www-data@hostname.com,它也回复了该地址。我不知道我可能忽略了什么:(

<?php

$vorname = $_POST['vorname'];
$nachname = $_POST['nachname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$club = $_POST['club'];
$handicap = $_POST['handicap'];
$spieler = $_POST['spieler'];
$bemerkungen = $_POST['bemerkungen'];
$from = 'Von: Kontaktformular'; 
$to = 'edited for this question'; 
$subject = 'Anmeldung';

$body = "Von: $vorname $nachname\n E-Mail: $email\n Telefon: $phone\n Club: $club\n Handicap: $handicap\n Spieler: $spieler\n Bemerkung: $bemerkungen ";

$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: $email" . "\r\n" .
  "Reply-To: $email" . "\r\n" .
  "X-Mailer: PHP/" . phpversion();

if(!isset($_POST['submit'])) {
if (mail ($to, $subject, $body, $from)) {
    header("Location: edited.html"); 
} else { 
    header("Location: edited.html"); 
}
}
?>

感谢任何提示!

1 个答案:

答案 0 :(得分:1)

看起来邮件功能中没有使用$ header。