How Do Small Businesses Add a Contact Form With PHP?

For Small business owners · Based on Traversy PHP Contact Form Build

// TL;DR

Small business owners can add a professional contact form to their website using PHP's built-in mail() function, avoiding monthly fees from third-party form services. The method uses two files—an HTML form on your main page and a PHP processor that emails submissions to your business mailbox. If you rely on Gmail, configure your hosting to forward messages from a domain email to your Gmail address. This approach works on any standard hosting plan and ensures customer inquiries land in your inbox reliably.

Why should a small business use PHP mail() instead of a form plugin?

Third-party form services and plugins often come with submission limits, branding on free plans, and recurring monthly costs. PHP's mail() function is built into your hosting—it costs nothing extra, has no submission caps, and keeps customer data entirely on your own server. For a small business that receives 5-50 inquiries per week, it is the most practical and cost-effective option.

The Traversy PHP Contact Form Build provides a clear, repeatable process: separate the HTML form from the PHP processor, gate all logic with isset(), capture POST data, send with proper headers, and redirect after sending. No coding framework needed.

How do you build a customer inquiry form for your business site?

Your form needs fields that capture what your team needs to respond effectively:

- Name — So you know who is contacting you

- Email — So you can reply

- Subject — So you can categorize or prioritize the inquiry

- Message — The details of their request

In your HTML, create a `

` with `action="contact_form.php"` and `method="post"`. Each input must have a `name` attribute that matches what the PHP processor expects. The submit button must include `name="submit"`—this is what the isset() gate checks.

Create `contact_form.php` as a separate file. Inside the isset() block, capture all fields, set `$mail_to` to your business domain email (like `info@yourbusiness.com`), build the From header with the customer's email, format a readable message body, call mail(), and redirect to `index.php?sent`.

How do you get contact form emails in your Gmail inbox?

PHP's mail() cannot deliver directly to Gmail—Google rejects these messages. The solution is simple and does not require any code changes:

1. Set `$mail_to` to an email on your hosted domain: `info@yourbusiness.com`.

2. In your hosting control panel, go to email settings.

3. Create a forwarding rule that sends all mail from `info@yourbusiness.com` to your Gmail address.

Every customer inquiry is now delivered to your domain mailbox and automatically forwarded to Gmail. You and your team see the message in Gmail and can reply normally.

What common mistakes should small business owners avoid?

The most frequent issues are:

- Testing on localhost — PHP mail() does not work on local development environments like XAMPP without complex configuration. Always upload to your live server to test.

- Sending directly to Gmail — Google blocks these emails. Use the forwarding workaround.

- Mismatched button names — If your submit button's name attribute doesn't match the isset() check, no email sends. Verify both say exactly `submit`.

- Missing From header — Without it, the email arrives with no sender info, making it impossible to reply to the customer.

- No redirect after sending — Without `header('Location: index.php?sent')`, refreshing the page sends duplicate emails.

What should you do next?

Upload your two files to your hosting, submit a test inquiry through the form, and check your hosted mailbox. Confirm the email arrives with the correct sender, subject, and formatted message. Set up Gmail forwarding if your team uses Gmail. Once confirmed, style the form to match your brand and publish. You now have a zero-cost, dependency-free contact system for your business.

// FREQUENTLY ASKED QUESTIONS

Will PHP mail() work on my GoDaddy or Bluehost hosting?

Yes, both GoDaddy and Bluehost support PHP and have mail transfer agents configured on their shared hosting plans. PHP's mail() function works out of the box. Upload your files, set $mail_to to an email on your hosted domain, and test by submitting the form on your live site.

How many emails can PHP mail() send per day?

Most shared hosting providers impose limits, typically between 200 and 500 emails per hour. For a small business contact form receiving under 50 inquiries daily, you will not approach these limits. If you expect high-volume submissions, contact your hosting provider for their specific limits or consider an SMTP service.

Can multiple team members receive contact form submissions?

Yes. You can add multiple recipients by separating email addresses with commas in the $mail_to variable, like 'info@yourbusiness.com, sales@yourbusiness.com'. Alternatively, set up a distribution list or alias in your hosting dashboard that forwards to multiple team members' addresses.