I am using the template that already have a simple contact form feature and the process form is very straightforward and I don't understand why I cannot receive any emails... I did run a debug test and it is working just fine. From what I read online that it seems that mail() function is no longer supported or doesn't actually send emails. Maybe you guys can help me out here and understand why this isn't working and how to fix it? Thank you in advance!
contact.php
<form method="post" id="contactForm" action="processForm.php">
<div class="clearfix">
<div class="grid_6 alpha fll"><input type="text" name="senderName" id="senderName" placeholder="Name *" class="requiredField" /></div>
<div class="grid_6 omega flr"><input type="text" name="senderEmail" id="senderEmail" placeholder="Email Address *" class="requiredField email" /></div>
</div>
<div><textarea name="message" id="message" placeholder="Message *" class="requiredField" rows="8"></textarea></div>
<input type="submit" id="sendMessage" name="sendMessage" value="Send Email" />
<span> </span>
processForm.php
<?php
// Define some constants
define( "RECIPIENT_NAME", "Jenna" );
define( "RECIPIENT_EMAIL", "your_mail@gmail.com" ); //left it standard for privacy reasons
define( "EMAIL_SUBJECT", "Visitor Message" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
</body>
</html>
<?php
}
?>
Also, It does return "Thanks for sending your message!..." when you test it out.
EDIT UPDATE: Thank you everyone but apparently it is working when I had uploaded to my server. It just took longer to get the email than I thought. All of my code was correct and there wasn't anything wrong with it. So Thank you for taking your time!!