【发布时间】:2017-03-14 15:27:16
【问题描述】:
我已联系数字海洋支持团队,他们认为我的 www/data 文件的文件权限不正确
“此错误表明您的站点存在权限问题。您需要确保 Web 服务器用户很可能是 www-data 有权访问使用表单发送邮件所需的文件和应用程序。您应该能够在您网站的访问日志中追踪尝试访问的确切文件名。” - 数字海洋支持团队
我检查了 nginx 访问日志
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;英特尔 Mac OS X 10_12_2)AppleWebKit/537.36(KHTML,如 壁虎)Chrome/56.0.2924.87 Safari/537.36"
我收到 405 not allowed 错误 - contact_me.php 文件权限
-rw-r--r-- 1 root root 1218 Mar 14 00:05 contact_me.php
这是我的 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;
?>
【问题讨论】:
标签: php nginx permissions