# AJAX Contact Form

The template comes with a simple PHP mail script which allows you to gather leads from your website without using any CMS or 3rd-party mailing tool.

Open 📄mail.php file from the root template folder with any text editor and change $recepient variable to your own e-mail address. Some other variables and text templates are also safe to customize.

<?php
  if ( $_POST ) {

    $recepient = 'user@example.com'; // your e-mail
    $sitename  = 'Rubenz Website'; // your site name
    $subject   = "New contact from "$sitename""; // subject template

    $name  = trim( $_POST['visitor_name'] );
    $email = trim( $_POST['visitor_email'] );
    $msg   = trim( $_POST['visitor_msg'] );

    $message = "
    -------------------<br><br>
    Visitor name: $name <br>
    Visitor email: $email <br><br>
    $msg
    <br><br>-------------------
    ";

    mail( $recepient, $subject, $message, "From: $name <$email>" . "rn" . "Reply-To: $email" . "rn" . 'X-Mailer: PHP/' . phpversion() . "rn" . 'Content-type: text/html; charset="utf-8"' );

  }

# Troubleshooting

If you are experiencing any issues with the mailing script, please contact your hosting provider for the assistance and make sure that:

  • Your hosting plan actually supports PHP and it's enabled in your account.
  • mail() function is allowed for execution.
  • Your domain is authorized to send mails.
  • Letters sent from your website are not going into spam folder