“此错误表示您网站中存在权限问题。您需要确保Web服务器用户最有可能访问使用该表单发送邮件所需的文件和应用程序的www数据。您应该能够在您网站的访问日志中跟踪尝试访问的确切文件名。“ - 数字海洋支持团队
70.54.134.32 - - [14 / Mar / 2017:14:58:34 +0000]“POST /contact_me.php HTTP / 1.1”405 584“https://cormaccrowley.com/”“Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_12_2)AppleWebKit / 537.36(KHTML,如 Gecko)Chrome / 56.0.2924.87 Safari / 537.36“
-rw-r--r-- 1 root root 1218 Mar 14 00:05 contact_me.php
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = 'c[MY-EMAIL-WAS-HERE]'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply@cormaccrowley.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
答案 0 :(得分:1)
目录中的文件需要由nginx正在运行的用户读取。您必须使用chown linux函数更改权限:
chown www-data:www-data contact_me.php