"This error indicates a permissions issue within your site. You will need to make sure that the web server user most likely www-data has access to the files and applications needed to send mail using the form. You should be able to track down the exact filenames of the attempted access in your site's access logs." - digital ocean support team
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, like 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.
"."Here are the details:
Name: $name
Email: $email_address
Phone: $phone
Message:
$message";
$headers = "From: noreply@cormaccrowley.com
"; // 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;
?>
The files within your directory will need to be readable by the user nginx is running as. You will have to change the permissions with the chown linux function : chown www-data:www-data contact_me.php