I have a contact page which made with the help of PHPMailer. The minimal code is as follows
<form class="form-horizontal" method="POST" action="Mail.php" name="contactForm">
...
</form>
This works perfectly fine, but whenever I try to open Mail.php explicitly on the webserver, the webserver sends blank
email every time. Here's a screenshot of email whenever I access Mail.php
Below is the minimal code from PHPMailer's Mail.php
$mail->Subject = $subject;
$mail->Body = "<b>From: </b>". $sender. "<br>" ." <b>Name: </b>". $yourName. "<br>". "<b> Message Body </b>" .$message;
$mail->AltBody = "<b>From: </b>". $sender. "<br>" ." <b>Name: </b>". $yourName. "<br>". "<b> Message Body </b>" .$message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo "Message has been sent....You're being redirected.....";
}
How can I restrict the user to explicitly access Mail.php?