---
url: https://docs.artemsemkin.com/velum/html/settings/contact-form.md
description: Get the contact form's messages by email and protect it from spam.
---

# Contact form

The contact form is on four pages: `contacts.html`, `contacts-classic.html`, `studio.html` and `horizontal-scroll.html`. It sends its fields to `mail.php`, a PHP script in the HTML folder that emails them to you, and shows the visitor a success or an error message without leaving the page.

## How to access

**HTML/mail.php**

```php
/** Who receives the messages */
$recipient = 'you@example.com';

/** The name the messages come from */
$sender_name = 'Velum';

/** Their subject */
$subject = 'New message from the contact form';

/** Cloudflare Turnstile's secret key; empty, no Turnstile check */
$turnstile_secret = '';
```

## What the host needs

PHP with a working `mail()` function: ask your host if you are unsure. A host that serves only static files (and a page opened from disk) cannot run `mail.php`: there every message ends on the error message. Live Server, on your own computer, is one of them, so test the form once the site is on your host.

## Receiving the messages

Each of the four pages sends its form to the same `mail.php`, so one address receives them all.

![The contact form of contacts.html, filled in and ready to send](https://docs.artemsemkin.com/velum/html/images/settings/contact-form-1.png)

#### ▶️ Step 1.

In `mail.php`, write your address in `$recipient`. Change `$sender_name` and `$subject` if you like.

#### ▶️ Step 2.

Upload `mail.php` and send a message from one of the four pages. The form then shows "Your submission was successful." in its place.

The email comes from `no-reply@` and your site's domain, under the name in `$sender_name`, with the visitor's address as its reply address: answering the email answers the visitor. It holds the name, the email address and the message.

## Changing the address in the error message

When a message cannot be sent, the form tells the visitor to write to an address instead. That address is in each of the four pages, not in `mail.php`:

```html
<p class="contact-form__answer paragraph"><span>Your submission failed because of an error. Please write to </span><a href="mailto:velum@example.com">velum@example.com</a><span> instead.</span></p>
```

The template's `velum@example.com` is also in the burger menu and the site footer, so one search and replace changes all of them: [Edit every page at once](../get-started/edit-every-page-at-once).

## Stopping spam

The form carries a hidden field that people never see. A bot that fills it in is told its message went out, and nothing is sent. For more, add Cloudflare Turnstile, a free check that most visitors pass without doing anything.

#### ▶️ Step 1.

In the [Cloudflare dashboard](https://dash.cloudflare.com/), open **Turnstile** and add your site, with its domain as the hostname. Cloudflare gives you a site key and a secret key.

#### ▶️ Step 2.

Put the site key in `js/config.js`:

```js
turnstileSiteKey: 'YOUR-SITE-KEY',
```

#### ▶️ Step 3.

Put the secret key in `mail.php`:

```php
$turnstile_secret = 'YOUR-SECRET-KEY';
```

The check starts when a visitor clicks into the form, and shows itself only when Cloudflare needs the visitor to prove something. With the secret key set, `mail.php` refuses a message Cloudflare has not passed, and the visitor sees the error message. Keep the secret key out of every page and script: it belongs in `mail.php` alone.

::: tip Trying it out first
Cloudflare's test keys try the form before you have keys of your own: site key `1x00000000000000000000AA` with secret key `1x0000000000000000000000000000000AA` always passes, and with `2x0000000000000000000000000000000AA` always fails. Put your own keys back before launch.
:::

Next: [Google Map](./google-map).
