Contact form does not work

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10035220
    markusweb
    Participant

    Hello, I can’t seem to get the contact form to work. It is very strange since I have changed the email-address in the contact-form.php. I will submit the index.html file. Help would be appreciated a lot!



    Template Version: index-corporate5
    #10035222
    Support
    Keymaster

    Hello,

    There are two issues:

    1) First you need include on footer of page the script view.contact.js:

    <script src="js/views/view.contact.js"></script>

    2) As you can see when we access the php file directly on browser, it’s returning error 500:
    https://infowebvalue.com/php/contact-form.php

    Error 500 can be caused by a lot of things. You mentioned that’s was working before, and the problem starts when you changed the variable $email. Check if you have a syntax error where you changed. Syntax errors can cause error 500.

    Case no success, please send us all code of php/contact-form.php you are trying. You can use a service like https://pastebin.com to generate a link with the code and share with us.

    Please try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    If you are satisfied with Porto HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10035226
    markusweb
    Participant

    Hello. The <script src=”js/views/view.contact.js”></script> is not included on my index.html. However, something seems to still be missing. I figured I could paste the contact-form.php here:
    <?php
    /*
    Name: Contact Form
    Written by: Okler Themes – (http://www.okler.net)
    Theme Version: 8.1.0
    */

    namespace PortoContactForm;

    session_cache_limiter(‘nocache’);
    header(‘Expires: ‘ . gmdate(‘r’, 0));

    header(‘Content-type: application/json’);

    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;

    require ‘php-mailer/src/PHPMailer.php’;
    require ‘php-mailer/src/SMTP.php’;
    require ‘php-mailer/src/Exception.php’;

    // Step 1 – Enter your email address below.
    $email = ‘[email protected]’;

    // If the e-mail is not working, change the debug option to 2 | $debug = 2;
    $debug = 0;

    // If contact form don’t has the subject input change the value of subject here
    $subject = ( isset($_POST[‘subject’]) ) ? $_POST[‘subject’] : ‘Define subject in php/contact-form.php line 29’;

    $message = ”;

    foreach($_POST as $label => $value) {
    $label = ucwords($label);

    // Use the commented code below to change label texts. On this example will change “Email” to “Email Address”

    // if( $label == ‘Email’ ) {
    // $label = ‘Email Address’;
    // }

    // Checkboxes
    if( is_array($value) ) {
    // Store new value
    $value = implode(‘, ‘, $value);
    }

    $message .= $label.”: ” . htmlspecialchars($value, ENT_QUOTES) . “<br>\n”;
    }

    $mail = new PHPMailer(true);

    try {

    $mail->SMTPDebug = $debug; // Debug Mode

    // Step 2 (Optional) – If you don’t receive the email, try to configure the parameters below:

    //$mail->IsSMTP(); // Set mailer to use SMTP
    //$mail->Host = ‘mail.yourserver.com’; // Specify main and backup server
    //$mail->SMTPAuth = true; // Enable SMTP authentication
    //$mail->Username = ‘[email protected]’; // SMTP username
    //$mail->Password = ‘secret’; // SMTP password
    //$mail->SMTPSecure = ‘tls’; // Enable encryption, ‘ssl’ also accepted
    //$mail->Port = 587; // TCP port to connect to

    $mail->AddAddress($email); // Add another recipient

    //$mail->AddAddress(‘[email protected]’, ‘Person 2’); // Add a secondary recipient
    //$mail->AddCC(‘[email protected]’, ‘Person 3’); // Add a “Cc” address.
    //$mail->AddBCC(‘[email protected]’, ‘Person 4’); // Add a “Bcc” address.

    // From – Name
    $fromName = ( isset($_POST[‘name’]) ) ? $_POST[‘name’] : ‘Website User’;
    $mail->SetFrom($email, $fromName);

    // Repply To
    if( isset($_POST[’email’]) ) {
    $mail->AddReplyTo($_POST[’email’], $fromName);
    }

    $mail->IsHTML(true); // Set email format to HTML

    $mail->CharSet = ‘UTF-8’;

    $mail->Subject = $subject;
    $mail->Body = $message;

    $mail->Send();
    $arrResult = array (‘response’=>’success’);

    } catch (Exception $e) {
    $arrResult = array (‘response’=>’error’,’errorMessage’=>$e->errorMessage());
    } catch (\Exception $e) {
    $arrResult = array (‘response’=>’error’,’errorMessage’=>$e->getMessage());
    }

    if ($debug == 0) {
    echo json_encode($arrResult);
    }


    #10035227
    markusweb
    Participant

    I believe it is something weird since I can’t get the mailchimp newsletter to work either. Everything else works properly!

    Thanks in advance!


    #10035232
    Support
    Keymaster

    Hello,

    I don’t see any issue with your contact-form.php. Seems you have a server side issue returning error 500 in all PHP files. The same occurs with the mailchimp/newsletter script:
    https://infowebvalue.com/php/newsletter-subscribe.php

    And that’s reason mailchimp newsletter it’s not working (the same reason for contact form).

    This case you should check the error logs in your server to see what’s causing the error 500. My suggestion for you is contact your hosting provider support.

    We hope this helps!

    Please try that and le us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    If you are satisfied with Porto HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10035236
    markusweb
    Participant

    It turned out to be an issue on the severs end!


    #10035238
    Support
    Keymaster

    Hello Markus,

    Great the issue is now resolved!

    If you need further assistance feel free to contact us.

    Kind Regards,

    Rodrigo.


    If you are satisfied with Porto HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


Viewing 7 posts - 1 through 7 (of 7 total)

This topic is marked as "RESOLVED" and can not rceive new replies.