我的网站上有联系表格,似乎没有发送电子邮件。当我测试它时,它在服务器上。
这是表格。
<form action="" method="post" name="form">
<input type="text" name="name" />
<input type="email" name="email" />
<textarea name="message" ></textarea>
<input name="submit" type="submit" value="Submit">
</form>
这是PHP代码。
<?php
if(isset($_POST["submit"])){
if($_POST["name"]==""||$_POST["email"]==""||$_POST["message"]==""){
echo "Please fill in the contact form";
}else{
$to = "example@gmail.com";
$subject = "Contact Form";
$name= $_POST['name'];
$email= $_POST['email'];
$message= $_POST['message'];
$headers = "From: example@gmail.com";
mail($to,$subject,$name,$email,$message,$headers);
}
}
?>
我已经将我的电子邮件地址更改为虚拟电子邮件地址,但是当我提交此表单时,我确实没有收到任何电子邮件。
提前致谢! :)
答案 0 :(得分:2)
<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
//syntax mail(to,subject,message,headers,parameters);
?>
答案 1 :(得分:0)