Hi
I’m trying to get a php mail form (phpmailer) to work on my test site but it fails with the error message of “connection-failed”
I am using google recaptcha and have done a couple of other sites using the exact same php files so really stuck as to what to try.
I have created the 2 google recaptcha keys and put them in the config.php file along with the 16 key google password for the SMTP email
I did see this topic from a few months ago with the exact same issue but that seemed to be a temporary issue - [ReCaptcha connection-failed on server side verify - tried all RequestMethods]
I have added the line
AddHandler php5-cgi .html
into the .htaccess file within the htdocs folder
The 2 files that need to be amended to make this work are config.php and submit.php
config.php (1.5 KB)
submit.php (3.1 KB)
From the error trapping, I can see that I get as far as the last line of the code below in submit.php:
> <?php
>
> require_once __DIR__.'/vendor/autoload.php';
> require_once __DIR__.'/functions.php';
> require_once __DIR__.'/config.php';
>
> session_start();
>
> // Basic check to make sure the form was submitted.
> if ($_SERVER['REQUEST_METHOD'] != 'POST') {
> redirectWithError("The form must be submitted with POST data.");
> }
>
> // Do some validation, check to make sure the name, email and message are valid.
> if (empty($_POST['g-recaptcha-response'])) {
> redirectWithError("Please complete the CAPTCHA.");
> }
>
> $recaptcha = new \ReCaptcha\ReCaptcha(CONTACTFORM_RECAPTCHA_SECRET_KEY);
> $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_REQUEST['REMOTE_ADDR']);
>
> if (!$resp->isSuccess()) {
> $errors = $resp->getErrorCodes();
> $error = $errors[0];
>
> $recaptchaErrorMapping = [
> 'missing-input-secret' => 'No reCAPTCHA secret key was submitted.',
> 'invalid-input-secret' => 'The submitted reCAPTCHA secret key was invalid.',
> 'missing-input-response' => 'No reCAPTCHA response was submitted.',
> 'invalid-input-response' => 'The submitted reCAPTCHA response was invalid.',
> 'bad-request' => 'An unknown error occurred while trying to validate your response.',
> 'timeout-or-duplicate' => 'The request is no longer valid. Please try again.',
> ];
>
> $errorMessage = $recaptchaErrorMapping[$error];
> redirectWithError("Please retry the CAPTCHA: ".$error);
I’m sure that more info might well be needed to help diagnose what the problem actually is so please let me know as any help is really appreciated
thanks