来自的PHP Contactform电子邮件

时间:2019-02-18 17:55:26

标签: php html email

我试图在我的网站上设置联系表格。我已经下载了一个例子。

在此联系表中,电子邮件中包含$ EmailFrom。 现在,我想将此$ EmailFrom添加到已发送的电子邮件的发件人字段中。

我尝试过:

$EmailFrom = "$EmailFrom";

但是我看来那是行不通的;(

<?php

$EmailFrom = "test@hotmail.com";
$EmailTo = "info@mydomain.nl";
$Subject = "Contactformulier";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

我期望这样:email sender

0 个答案:

没有答案