我正在尝试使用
这是参考此答案PHP mail function 'from' address。我对php很陌生,如果答案很明显,还请见谅,但这让我感到很困扰。
下面是表单的代码,但我似乎无法使其工作? 有人知道如何/在哪里将其与下面的代码集成吗?
敬礼。
$headers = "From: webmaster@example.com\r\n";
在PHP中设置联系表单的“发件人”电子邮件地址为“name@companyname.com”。这是参考此答案PHP mail function 'from' address。我对php很陌生,如果答案很明显,还请见谅,但这让我感到很困扰。
下面是表单的代码,但我似乎无法使其工作? 有人知道如何/在哪里将其与下面的代码集成吗?
敬礼。
<?php
if($_POST['submit']) {
if(!$_POST['name']) {
$error="<br>- Please enter your name";
}
if(!$_POST['email']) {
$error.="<br>- Please enter your email";
}
if(!$_POST['telephone']) {
$error.="<br>- Please enter your telephone number";
}
if(!$_POST['message']) {
$error.="<br>- Please enter your message";
}
if(!$_POST['checkbox']) {
$error.="<br>- Please confirm you agree to the Privacy Policy";
}
if ($error) {
$result='<div class="alert error">Whoops, there is an error. Please correct the following: '.$error.'</div>';
} else {
mail("name@company.com", "Contact Message", "Name: ".htmlspecialchars($_POST['name'])."
Email: ".htmlspecialchars($_POST['email'])."
Telephone: ".htmlspecialchars($_POST['telephone'])."
Company: ".htmlspecialchars($_POST['company'])."
Budget: ".htmlspecialchars($_POST['budget'])."
Message: ".htmlspecialchars($_POST['message']));
{
$_POST= array();
$result='<div class="alert thankyou" role="alert">THANK YOU! WE\'LL BE IN TOUCH SHORTLY...</div>';
}
}
}
?>
mail()
函数。https://github.com/PHPMailer/PHPMailer - benJ