I've made a page which will receive 3 variables and send email according to the data being sent to that page. But when I send the data from a form I get HTTP ERROR 500 when POST is used. The same code is working when GET Method is used and when data is sent in the url. What could be the mistake?
<!doctype html>
<html>
<head>
<title>MAIL</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div>
<?php
$emailTo=$_POST['to_address'];
$subject=$_POST['subject'];
$body="$_POST['body'];
$headers="From: myemail@mysite.com";
if (mail($emailTo, $subject, $body, $headers)) {
echo "Mail sent successfully!";
} else {
echo "Mail not sent!";
}
?>
</div>
</body>
</html>