Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Form handler mail() blocked by host: how to find and fix it

OPS-081High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Many contact forms, especially custom PHP handlers and older plugins, send email with the PHP function mail(). It hands the message to the web server's local mail program (often sendmail or Exim). No login is needed, which is why it is easy to use and easy to abuse.

Because spammers abuse it, many hosts turn it off. They may list mail in disable_functions in php.ini, remove the sendmail binary, cap messages per hour, or accept the message and then discard it. In each case the form usually still shows a success message. Nothing tells the visitor, or you, that the email was lost.

Why it costs you leads or sales

The visitor did everything right: they filled in the form and saw a thank-you page. You never get the enquiry, so nobody replies. They assume you ignored them and go to a competitor. Because there is no error, this can run for weeks before anyone notices a quiet inbox.

Where the lead is lost
  1. Visitor submits formPage shows a thank-you message
  2. Handler calls mail()Host blocks or drops the message
  3. Email to inboxNever arrives
  4. Your replyNever happens

The form works on screen, but the email never leaves the server.

Leads received vs leads submittedExample numbers
Leads received vs leads submitted (example)Submitted: 40 leads per week; Received (mail() blocked): 4 leads per week; Received (SMTP/API): 40 leads per week0153140440SubmittedReceived (mail() bloc…Received (SMTP/API)leads per week

Example: 40 people submit the form each week, but only the few emails that slip through reach you.

How to check if your site has it

Confirm mail() is the cause
  1. Submit a real test lead

    Use an address you control, ideally at a different domain from your site. Wait 10 minutes and check inbox, spam and junk.

  2. Check whether mail() is disabled

    Look at phpinfo() or your host's PHP settings for disable_functions. If mail is listed, it is blocked.

  3. Test mail() directly

    Upload the snippet below, open it once in your browser, then delete it. A false result means PHP could not hand the message over. A true result only means it was accepted, not delivered.

  4. Read the server mail log

    In your hosting panel look for mail logs or Track Delivery. Messages marked rejected, deferred or limit exceeded point to a host block.

mail-test.php (delete after use)php
<?php
$to = 'you@example.com';
$ok = mail($to, 'mail() test', 'Test from the server', 'From: test@yourdomain.com');
var_dump($ok);
var_dump(ini_get('disable_functions'));

How to fix it

The reliable fix is to stop using bare mail() and send through an authenticated service: your domain's mailbox over SMTP, or a transactional email provider's SMTP or API. Then add SPF, DKIM and DMARC records so receivers trust the mail.

Switch the form to authenticated sending
  1. Install an SMTP plugin

    Use an SMTP or email-API plugin such as WP Mail SMTP or FluentSMTP.

  2. Enter your mail provider details

    Choose your provider or Other SMTP, then add host, port, encryption and credentials. Use an address on your own domain as the From email.

  3. Send the plugin's test email

    Then submit your real form. Form plugins like Contact Form 7 and Gravity Forms use wp_mail(), so they pick up the change.

PHPMailer with authenticated SMTPphp
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';

$mail = new PHPMailer(true);
try {
  $mail->isSMTP();
  $mail->Host       = getenv('SMTP_HOST');
  $mail->SMTPAuth   = true;
  $mail->Username   = getenv('SMTP_USER');
  $mail->Password   = getenv('SMTP_PASS');
  $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
  $mail->Port       = 587;
  $mail->setFrom('leads@yourdomain.com', 'Website');
  $mail->addAddress('you@yourdomain.com');
  $mail->Subject = 'New website lead';
  $mail->Body    = 'Name: ' . strip_tags($_POST['name'] ?? '');
  $mail->send();
} catch (Exception $e) {
  error_log('Mail failed: ' . $mail->ErrorInfo);
}
Make the new mail trusted
  1. Add SPF

    Add your sending provider to the domain's SPF TXT record. Keep only one SPF record.

  2. Turn on DKIM

    Publish the DKIM record your provider gives you in DNS.

  3. Add DMARC

    Publish a DMARC record, starting with p=none to monitor.

  4. Add a backup

    Also save each lead in a CRM or database, so a mail failure never loses the enquiry.

Sending method

mail() on the host

  • No login, easy to block
  • Silent failures
  • Often lands in spam or vanishes

Authenticated SMTP or API

  • Signed with SPF and DKIM
  • Errors are reported
  • Delivery you can verify

How to confirm it's fixed

Fix verification
  • A test lead arrives in the inbox within a few minutes
  • The message is not in spam
  • The From address is on your own domain
  • SPF, DKIM and DMARC pass in the message headers
  • The lead also appears in your CRM or database
  • The temporary mail-test.php file is deleted

How to prevent it happening again

Hosts change mail rules, migrations reset PHP settings, and mail credentials expire. Keep a record of how forms send mail, store leads somewhere besides email, and test the full path on a schedule instead of waiting for a customer to complain.

How an unnoticed failure unfolds
  1. Day 0

    Host moves the site or tightens mail rules

  2. Day 1

    Forms still show success, emails stop

  3. Day 14

    Someone notices the inbox is oddly quiet (example timing)

  4. Day 15

    Sending moved to SMTP, test lead arrives

How FunnelGuard handles this

FunnelGuard detects this today. Its robot visitor fills in and submits your real lead form on a schedule, then checks whether the test lead actually reaches the inbox and CRM. When the form succeeds on screen but the email does not arrive, the check reports delivery_failed.

A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. FunnelGuard tells you delivery failed; it does not read your server config, so use the steps above to confirm that mail() is the reason. Test submissions are marked with utm_source=funnelguard and fg_test=1. The Free plan covers 1 site and 2 journeys with daily checks and no card.

A form that succeeds but sends no email

The visitor sees success, but the email never reaches you.

Questions people ask

Why is my contact form not sending emails?

A common cause is that your host blocks or drops PHP's mail() function. The form still shows a success message, but the email never leaves the server. Send through authenticated SMTP or an email API instead, then submit a test lead to check.

How do I know if my host has disabled mail()?

Check disable_functions in phpinfo() or your host's PHP settings for the word mail. You can also check your host's mail logs for rejected or deferred messages. The only proof of delivery is a test email arriving in a real inbox.

Why does mail() return true but no email arrives?

mail() returns true when the local mail program accepts the message, not when it is delivered. The host or the receiving server can still drop it, for example for a missing SPF or DKIM record or a sending limit.

How do I replace PHP mail() with SMTP?

Use a library such as PHPMailer, or an SMTP plugin on WordPress. Enter your mail provider's host, port 587 with STARTTLS, and credentials, and use a From address on your own domain. Then send a test.

Do I need SPF, DKIM and DMARC for form emails?

Yes. These DNS records prove your mail is genuine. Without them, form emails often land in spam or are rejected, even when sent through SMTP.

Can I rely on email alone to receive leads?

It is safer not to. Also store each submission in a CRM or database so a mail failure does not lose the lead. Then email is a notification, not the only copy.

How can I detect when form emails stop arriving?

Run a scheduled test that submits the form and checks the email arrives. FunnelGuard does this with a robot visitor and alerts you when delivery fails, with a screenshot and a likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: delivery_failed.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.