Languages and runtimes
A PHP contact form without mail()
PHP's mail() function is the most common way a contact form gets built and the most common reason it silently stops working: no SPF, no DKIM, shared-host IP reputation, and mail that lands in spam with no delivery log to check. You do not need a mail server. Point the form at an endpoint - or forward from PHP with cURL if you want to validate first - and get delivery records you can actually inspect.
Setup
Copy your endpoint
Create a form in the dashboard.
Point the form at it
The simplest change: swap action="send.php" for the endpoint URL and delete send.php.
Or forward with cURL
Keep your PHP handler if it does something useful, and forward the payload instead of calling mail().
PHP examples
Swap in your own endpoint and these run as-is.
The whole migration, if your PHP script only ever called mail().
<form action="https://send.webforms.to/wft_your_key" method="POST"> <input type="text" name="name" required /> <input type="email" name="email" required /> <textarea name="message" required></textarea> <input type="hidden" name="_next" value="https://example.com/thanks.php" /> <button type="submit">Send</button> </form>
Server-side forwarding, for when you need to validate or log first.
<?php
$payload = [
'name' => $_POST['name'] ?? '',
'email' => $_POST['email'] ?? '',
'message' => $_POST['message'] ?? '',
'_subject' => 'New enquiry from the website',
'_replyto' => $_POST['email'] ?? '',
];
$ch = curl_init('https://send.webforms.to/wft_your_key');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 10,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!empty($response['ok'])) {
header('Location: /thanks.php');
exit;
}
echo htmlspecialchars($response['message'] ?? 'Something went wrong.');PHP form FAQ
Because mail sent straight from a web host usually has no SPF or DKIM alignment for your domain and shares an IP with every other site on that server. Sending through a proper provider with authenticated domains fixes the deliverability problem, and gives you a delivery log when something does fail.
Not for the form. If your handler only formatted and sent an email, delete it and point the form's action at your endpoint directly.
Related guides
Ready to wire up your PHP form?
Free for 300 submissions a month. Endpoint in under a minute, no card required.
Start free