Hello everyone.. I know next to nothing about PHP but I'm trying to set up a mail form on a html web page. The code I've used should work, but for some reason the email wont send. When I hit send, the message pops up saying that it sent, but it doesnt send. What am I missing or doing wrong?
Here's the code
<?php function spamcheck($field) { //filter_var() sanitizes the e-mail //address using FILTER_SANITIZE_EMAIL $field=filter_var($field, FILTER_SANITIZE_EMAIL); //filter_var() validates the e-mail //address using FILTER_VALIDATE_EMAIL if(filter_var($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_REQUEST['email'])) {//if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==FALSE) { echo "Invalid input"; } else { //send email $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("someone@something.com", "Subject: $subject", $message, "From: $email" ); echo "Sent. Thank you!"; } } else //if "email" is not filled out, display the form { echo "<form method='post' action='contact.php'> What's your name? <br /> <input name='name' type='text' required /> <br /> What's your Email address? <br /> <input name='email' type='text' required> <br /> What is the matter regarding? <br /> <input name='subject' type='text' required> <br /> What is your message? <br /> <textarea name='message' rows='15' cols='50' required></textarea> <br /> <br /> <input type='submit' value='Send'> </form>"; } ?>
Keep in mind that the someone@something.com is not the email I tried sending it to. I've tried multiple email accounts I have on yahoo and gmail with no luck. And yes, the file is saved in a folder on a server that has php installed.
Thank you for your time!!!