Luiz Luiz - 1 year ago 75
Javascript Question

Contact form won't send the email


I download this website template from themefisher, but I can't get the contact form to work. I changed the
section in the php file to my email address, so I can receive it; but after filling the form and sending it, even thought I got a success message, there's nothing in my inbox or junk.


You can see the live preview here; or download the template here.


$(function() {

preventSubmit: true,
submitError: function($form, event, errors) {
// additional error messages or events
submitSuccess: function($form, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var name = $("input#name").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
var message = $("textarea#message").val();
var firstName = name; // For Success/Failure Message
// Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = name.split(' ').slice(0, -1).join(' ');
url: "././mail/contact_me.php",
type: "POST",
data: {
name: name,
phone: phone,
email: email,
message: message
cache: false,
success: function() {
// Success message
$('#success').html("<div class='alert alert-success'>");
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
$('#success > .alert-success')
.append("<strong>Your message has been sent. </strong>");
$('#success > .alert-success')

//clear all fields
error: function() {
// Fail message
$('#success').html("<div class='alert alert-danger'>");
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
$('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
$('#success > .alert-danger').append('</div>');
//clear all fields
filter: function() {
return $(this).is(":visible");

$("a[data-toggle=\"tab\"]").click(function(e) {

/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {


// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
echo "No arguments Provided!";
return false;

$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

// Create the email and send the message
$to = ''; // Add your email address inbetween the '' replacing - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From:\n"; // This is the email address the generated message will be from. We recommend using something like
$headers .= "Reply-To: $email_address";
return true;

Answer Source

You need an external server to send an email. It is not possible to send an email on a local server using PHP.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download