【发布时间】:2018-09-05 14:55:54
【问题描述】:
<?php
if(isset($_POST['email'])) {
$user_email = $_POST['email']; // this is just grabbed form the user email field
$email_to = "btndeals@btn.deals"; // where is the email going?
$fullname = $_POST['fname']; // get the full name from hte $_POST data
$subject = $_POST ['subject']; // what is the email subject?
$message = $_POST['message']; // get the message from the $_POST data
// ...geting data
if(mail($email_to, $fname, $subject, $message, "From:" . $email)) {
//the email got sent!!!
//you can echo html out here :)
echo "<strong>Sucessfully sent</strong>";
} else {
//email didn't work!
//you can out html here :)
echo "Error";
}
}
?>
在服务器上运行代码时,它不断出现错误,有人可以帮助我吗,我是 php 新手,所以我还在学习如何使用它。
【问题讨论】:
-
您的网站可能禁用了邮件发送功能,您应该检查一下。
-
您使用的是什么服务器?我问是因为在某些服务器中您必须启用邮件服务
-
你好曹兰,请提供更多相关信息,例如错误信息是什么
-
如果有帮助,我使用了液体服务器
-
您使用的
mail函数有误。它需要四个参数,而不是五个。请在此处查看手册中的函数规范:php.net/manual/en/function.mail.php 编辑:我的错误,它确实需要五个参数,其中两个是可选的,但是您使用的参数顺序是错误的。第二个参数应该是主题,第三个参数应该是消息。您将主题和消息分别作为第三个和第四个参数,所以显然它不起作用。