send.webforms.toRead the docs →

templatesguides

Why your ThemeForest template's contact form isn't working

We read the form code that ships in popular ThemeForest, Envato and TemplateMonster templates. The failures come down to two things, and both take minutes to fix.

WebForms 3 min read

You buy a template, upload it, fill in the contact form to test it, and nothing arrives. Or the form says "Oops! Something went wrong" while the message lands in your inbox anyway. It is one of the most common complaints in template comment threads, and it is rarely the author's fault. We read the contact form code that ships in a range of popular marketplace templates to see why, and the answer comes down to two things.

Reason one: the form posts to a PHP script

Almost every HTML template's contact form posts to a PHP file that comes in the download: contact.php, mail.php, php/contact-form.php, or bat/rd-mailform.php on TemplateMonster templates. That script takes the fields and sends you an email with PHP's mail function or PHPMailer.

That only works on a server that runs PHP and is allowed to send mail. Static hosts like GitHub Pages and Netlify run no PHP, so the POST fails, often with 405 Not Allowed. Some cloud providers block outgoing mail ports by default. And shared hosting that does run PHP can still send these emails to spam, because they come from the web server rather than a real mail domain.

The fix is to stop needing PHP: point the form's action at a form backend endpoint, which receives the submission, filters spam, stores it and emails it to you.

contact.html
<!-- Before -->
<form id="contact-form" action="php/contact.php" method="POST">

<!-- After -->
<form id="contact-form" action="https://send.webforms.to/wft_your_key" method="POST">

Reason two: the script expects a reply nobody sends

Changing the action fixes plain forms, which reload the page on submit. But most templates send the form with JavaScript so the page does not reload, and each script decides success in its own way. Here is what we found:

  • The common ajax-mail.js pattern shows whatever text the server sends back. A JSON reply shows as "[object Object]", and an HTML page shows as a wall of markup.
  • Start Bootstrap's contact_me.js has the PHP address written into the script itself, so changing the form's action does nothing.
  • RD Mailform, used by many TemplateMonster templates, only shows success when the reply is exactly the text MF000. Anything else shows "Aw, snap! Something went wrong", even when the message was sent.
  • Canvas, a long-standing ThemeForest bestseller, asks for JSON and reads alert and message fields, so it works with a backend that replies that way.

There is also a jQuery detail that catches people out. jQuery never adds the X-Requested-With header to a request for another domain, and only asks for JSON when the script sets dataType to json. So a form backend cannot tell that a template's script wants JSON, and sends the normal thank-you page instead. The message arrives; the template shows an error.

The fix, for most templates

Add one option to the $.ajax call so it asks for JSON, and show the message field from the reply. With WebForms, the JSON reply includes ok, alert set to success or error, and a message you can display.

js/ajax-mail.js
$.ajax({
  type: "POST",
  url: $(form).attr("action"),
  data: $(form).serialize(),
  dataType: "json"                    // ask for JSON
}).done(function (response) {
  $(formMessages).text(response.message);   // not the raw response
});

If a template's script is hard to follow, or expects a code like MF000, it is simpler to remove the script's hook (on RD Mailform templates, the rd-mailform class) and add a few lines of fetch that send the form, ask for JSON and show the message. The guides linked below have the exact code for each pattern.

WordPress and Elementor template kits

Template kits on Envato Elements are a different case: they rely on a form plugin rather than PHP in the template. Elementor Pro's Form widget can send each submission to an outside URL with its Webhook action, which is enough to forward it to a form backend. Elementor accepts the webhook only when the reply is a 200, so leave any redirect off the form you send it to.

A quick checklist

  1. Find the form on the contact page and note its action and any script that handles it.
  2. Set the action to your form backend endpoint, keeping method POST and the field names.
  3. If a script submits the form, add dataType: "json" and show response.message, or replace the script with a short fetch.
  4. Remove the template's PHP mail files and any reCAPTCHA check that posts to PHP.
  5. Send a test from the live site, not from your computer, and check your inbox.

Questions

Why does my ThemeForest template's contact form not send emails?
It posts to a PHP script that ships with the template, such as contact.php or mail.php, and that script needs a server running PHP that is allowed to send mail. Static hosts like GitHub Pages and Netlify run no PHP, so the request fails. Point the form at a form backend endpoint instead.
Why does the form show an error even though I received the message?
The template's script expects a specific reply, such as plain text, a code like MF000, or JSON. Cross-domain jQuery requests do not ask for JSON unless the script sets dataType to json, so they get a different reply and show an error. Ask for JSON and read the message field.
What does "Aw, snap! Something went wrong" mean?
It is RD Mailform's MF255 code, used by many TemplateMonster templates: the script got a reply that was not one of its codes, usually because PHP is not running. Replace RD Mailform with a form backend endpoint and a short fetch script.
Can I make a template's contact form work without PHP?
Yes. Set the form's action to a form backend such as WebForms, and if the template submits with jQuery, add dataType: "json" to its $.ajax call. The submissions are emailed to you, and the site can live on any static host.

Make your template's form work in minutes

Point the form at a WebForms endpoint and get every submission by email, spam filtered and stored. Free for 300 a month, no PHP or mail server needed.