Template marketplaces
Make a TemplateMonster template's contact form work
Short answer
Many TemplateMonster HTML templates use RD Mailform, which posts to bat/rd-mailform.php and only counts a reply of MF000 as success. Set the form action to your WebForms endpoint, remove the rd-mailform class so its script stops handling the form, and add a short fetch script. Submissions then arrive by email with no PHP.
If your template's contact form has the class rd-mailform and a bat/ folder, it uses RD Mailform: a PHPMailer script configured in bat/rd-mailform.config.json, and a script that shows "Successfully sent!" only when the server replies with the code MF000. Any other reply shows "Aw, snap! Something went wrong", even when the message was sent. Swapping it for WebForms takes a few minutes and needs no PHP or SMTP settings.
Setup
Create a form and copy its endpoint
Sign up, create a form, and copy the endpoint URL. Submissions are emailed to your verified address by default.
Change the form
Find
<form class="rd-mailform" ... action="bat/rd-mailform.php">. Setactionto your endpoint and removerd-mailformfrom the class list, so the template's script no longer intercepts it. Keep the other classes so the styling stays.Add the submit script
Paste the short fetch script below at the end of the page. It sends the form, asks WebForms for JSON, and shows the message it gets back in the form's output element.
Remove the bat folder
Delete
bat/rd-mailform.php, its config and the PHPMailer files. They are no longer used, and the config file may hold SMTP credentials you do not want published.Send a test
Submit the form on the live site; it appears in your inbox and the dashboard within seconds.
TemplateMonster examples
Swap in your own endpoint and these run as-is.
<!-- Before -->
<form class="rd-mailform" data-form-output="form-output-global"
data-form-type="contact" method="post" action="bat/rd-mailform.php">
<!-- After: rd-mailform class removed, action is your endpoint -->
<form class="contact-form" id="contact-form" method="post"
action="https://send.webforms.to/wft_your_key">Add before `</body>`:
<!-- Replaces the template's form script entirely -->
<script>
document.querySelector("#contact-form").addEventListener("submit", async (e) => {
e.preventDefault();
const form = e.target;
const out = form.querySelector(".form-message") ?? form.appendChild(document.createElement("p"));
const body = new FormData(form);
// So "Reply" on the notification email goes to the visitor.
if (body.get("email")) body.set("_replyto", body.get("email"));
const res = await fetch(form.action, {
method: "POST",
body,
headers: { Accept: "application/json" },
});
const data = await res.json().catch(() => ({ ok: false }));
out.textContent = data.ok ? data.message : "Sorry, something went wrong. Please try again.";
if (data.ok) form.reset();
});
</script>What RD Mailform's error codes mean
RD Mailform's script reads a five character code from the server and shows the matching message. Seeing one of these usually means the PHP side failed:
MF000Successfully sent: the only code it treats as success.MF001Recipients are not set: no recipient in the config or PHP file.MF002Form will not work locally: the PHP refuses local addresses.MF254Something went wrong with PHPMailer: the mail could not be sent.MF255Aw, snap! Something went wrong: any reply that is not one of the codes, including a missing PHP server.
Why the template's contact form does not send
Most marketplace HTML templates post the form to a PHP file that ships with the template, such as contact.php, mail.php, php/contact-form.php or bat/rd-mailform.php. That script calls PHP's mail function or PHPMailer to send you an email. It only works on a server that runs PHP and is allowed to send mail.
Static hosting runs no PHP at all, so on hosts like GitHub Pages and Netlify the POST fails, often with 405 Not Allowed. Some cloud providers, DigitalOcean among them, block outgoing mail ports by default. 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.
Pointing the form at a WebForms endpoint removes the PHP step. The submission goes to WebForms, which checks it for spam, stores it, and emails it to you, or sends it to Slack, Discord, Telegram or a webhook on Pro.
Worth knowing
- The template clears the form even when RD Mailform reports an error, so a visitor may think the message was lost when it was not. The replacement script only clears it after WebForms confirms.
- If the template also checks reCAPTCHA through
bat/reCaptcha.php, remove that check: without PHP it always fails. WebForms filters spam without a CAPTCHA. - Not every TemplateMonster item uses RD Mailform; many are now from other vendors. If there is no
rd-mailformclass, follow the ThemeForest guide instead.
TemplateMonster form FAQ
It is RD Mailform's code MF255: the script got a reply that was not one of its codes, usually because PHP is not running or failed. Replacing RD Mailform with a WebForms endpoint removes the PHP step.
In bat/rd-mailform.config.json or $recipients in bat/rd-mailform.php. With WebForms you set it in the dashboard instead, and can send to several addresses, Slack or a webhook.
Yes. Only the rd-mailform class and the action change; the inputs, classes and layout stay as they are.
Related guides
Where TemplateMonster submissions can go
The guide above gets the submission to your endpoint. From there it can land anywhere: one destination on Free, several on Pro.
Need the form markup too? The template gallery has complete forms for contact, waitlist, job application and more, and the form generator builds one field by field.
Ready to wire up your TemplateMonster form?
Free for 300 submissions a month. Endpoint in under a minute, no card required.
Start free