I have posted a website on github pages, and have a contact form written in php. However, when you try to fill out and send the form, I get a 405 error. What could be the problem?
When I tested this before putting it out to the public, I could easily send emails from the contact form and recieved them fine too. However now it seems to not work correctly.
This is how my php file looks like:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$to = "mymail"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$contact_name = $_POST['contact_name'];
$phone_number = $_POST['phone_number'];
$subject = "Someone messaged you from you. Website";
$subject2 = "Copy of your messa";
$contact_message = "heir phone number: ";
$message2 = "Here you ad.";
$headersReply = 'From: ' . $to . "\r\n" .
'Reply-To: ' . $to . "\r\n";
$headersReply2 = 'From: ' . $from . "\r\n" .
'Reply-To: ' . $from . "\r\n";
mail($to,$subject,$contact_message, $headersReply2);
mail($from,$subject2,$message2, $headersReply); // sends a copy of the message to the sender
}
?>
A 405 error is a Method (i.e. POST) Not Allowed error.
Since Github Pages does not support any kind of server side programming (including PHP), a POST request is pointless (there is nothing that could process the data) so they are not allowed.