【问题标题】:"From" and "Reply-to" not woking in my PHP Contact form“发件人”和“回复”在我的 PHP 联系表单中不起作用
【发布时间】:2015-04-26 06:25:02
【问题描述】:

我设置了一个简单的 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"); 
}
}
?>

感谢任何提示!

【问题讨论】:

  • stackoverflow.com/questions/19007032/… 可能重复?顺便说一句,当你只是静态地发送电子邮件时会发生什么,它会起作用吗?
  • 所以$headers 什么都没用?
  • 尝试调试 $email (如:echo($email) )看看是否正确:没有奇怪的字符或尾随空格或换行......

标签: php html contact


【解决方案1】:

您的邮件功能中似乎没有使用 $headers。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多