1. Go to this page and download the library: Download recranet/craft-secure-forms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
recranet / craft-secure-forms example snippets
use craft\helpers\App;
return [
// Email
'toEmail' => App::env('SECURE_FORMS_TO_EMAIL') ?: null, // null = system email address
'prependSubject' => App::env('SECURE_FORMS_PREPEND_SUBJECT') ?: 'New contact form submission',
'notificationTemplate' => App::env('SECURE_FORMS_NOTIFICATION_TEMPLATE') ?: '_emails/notifications/contact',
'enableConfirmationEmail' => App::env('SECURE_FORMS_CONFIRMATION_ENABLED') ?? true,
'confirmationTemplate' => App::env('SECURE_FORMS_CONFIRMATION_TEMPLATE') ?: '_emails/confirmations/contact',
// Storage
'saveSubmissions' => App::env('SECURE_FORMS_SAVE_SUBMISSIONS') ?? true,
'saveSpamSubmissions' => App::env('SECURE_FORMS_SAVE_SPAM_SUBMISSIONS') ?? true,
// Spam protection — 'silent' pretends success so bots learn nothing
'spamAction' => App::env('SECURE_FORMS_SPAM_ACTION') ?: 'silent', // or 'error'
'honeypotEnabled' => App::env('SECURE_FORMS_HONEYPOT_ENABLED') ?? true,
'honeypotParam' => App::env('SECURE_FORMS_HONEYPOT_PARAM') ?: 'honeyPotProtection',
// Minimum seconds between rendering and submitting a form (0 disables).
// Only applies to forms that render craft.secureForms.timestamp().
'minSubmitSeconds' => App::env('SECURE_FORMS_MIN_SUBMIT_SECONDS') ?? 3,
// Turn on once every form emits the timestamp field: a submission without
// one then counts as spam instead of being skipped
'ecaptcha-enterprise provider (createAssessment API)
'recaptchaProjectId' => '$RECAPTCHA_PROJECT_ID',
'recaptchaApiKey' => '$RECAPTCHA_API_KEY',
'turnstileSiteKey' => '$TURNSTILE_SITE_KEY',
'turnstileSecretKey' => '$TURNSTILE_SECRET_KEY',
];