contact form not working

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #10036496
    umbrella
    Participant

    Hello,

    My contact form is not working. Is not sending the message.
    The page where you can find the page is
    http://www.famileto.ro/2021/demo-cleaning-services-contact.html

    below the contact-form.php file:

    <?php
    /*
    Name: Contact Form
    Written by: Okler Themes – (http://www.okler.net)
    Theme Version: 8.3.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.famileto.ro’; // Specify main and backup server
    //$mail->SMTPAuth = true; // Enable SMTP authentication
    //$mail->Username = ‘[email protected]’; // SMTP username
    //$mail->Password = ‘ddddddd’; // 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);
    }


    #10036515
    Support
    Keymaster

    Hello, first thanks for your purchase and sorry the delay for this reply.

    The contact form file is returning error 500 in your server:
    http://www.famileto.ro/2021/php/contact-form.php

    Error 500 can be caused by more than one reason. The most common are syntax error or PHP version.
    – Check the PHP version: Make sure you have a minimum 5.6+ PHP version running in your server.
    – Regarding syntax error we did not found any error in your contact form file.

    If even so the problem persist, please share with us the error_log file of your server (the .txt file where PHP errors are registered). This way we can know what’s the exactly error.

    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


    #10036568
    umbrella
    Participant

    Hello again,
    I followed your advice and talked with the hosting company and they upgraded the php to 5.6. But the problem is still there. They told me:

    “You should check and verify the sending of messages is using SMTP authentication. So, we recommend to contact your programmer to use SMTP authentication with user and password with a email address on that domain.
    The setting should be something like this:
    Protocol: SMTP
    Host: localhost:
    Port: 25 or 587
    Address: [email protected]
    Password: your password
    field FROM: should be identical with the address ([email protected])”

    So, I made the changes in the contact-form.php and introduce debug = 2 and changed the following block:

    // 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.famileto.ro’; // Specify main and backup server
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->Username = ‘[email protected]’; // SMTP username
    $mail->Password = ‘mypassword’; // SMTP password
    $mail->SMTPSecure = ‘tls’; // Enable encryption, ‘ssl’ also accepted
    $mail->Port = 587; // TCP port to connect to

    Now I get the following message:

    Error! A aparut o eroare la trimiterea mesajului.
    2021-03-01 14:53:44 SERVER -> CLIENT: 220-s66.rohost.com ESMTP Exim 4.93 #2 Mon, 01 Mar 2021 16:53:44 +0200 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
    2021-03-01 14:53:44 CLIENT -> SERVER: EHLO http://www.famileto.ro
    2021-03-01 14:53:44 SERVER -> CLIENT: 250-s66.rohost.com Hello http://www.famileto.ro [46.102.145.144]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
    2021-03-01 14:53:44 CLIENT -> SERVER: STARTTLS
    2021-03-01 14:53:44 SERVER -> CLIENT: 220 TLS go ahead
    2021-03-01 14:53:44 CLIENT -> SERVER: EHLO http://www.famileto.ro
    2021-03-01 14:53:44 SERVER -> CLIENT: 250-s66.rohost.com Hello http://www.famileto.ro [46.102.145.144]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
    2021-03-01 14:53:44 CLIENT -> SERVER: AUTH LOGIN
    2021-03-01 14:53:44 SERVER -> CLIENT: 334 VXNlcm5hbWU6
    2021-03-01 14:53:44 CLIENT -> SERVER: [credentials hidden]
    2021-03-01 14:53:44 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
    2021-03-01 14:53:44 CLIENT -> SERVER: [credentials hidden]
    2021-03-01 14:53:44 SERVER -> CLIENT: 235 Authentication succeeded
    2021-03-01 14:53:44 CLIENT -> SERVER: MAIL FROM:<[email protected]>
    2021-03-01 14:53:44 SERVER -> CLIENT: 250 OK
    2021-03-01 14:53:44 CLIENT -> SERVER: RCPT TO:<[email protected]>
    2021-03-01 14:53:44 SERVER -> CLIENT: 250 Accepted
    2021-03-01 14:53:44 CLIENT -> SERVER: DATA
    2021-03-01 14:53:44 SERVER -> CLIENT: 354 Enter message, ending with “.” on a line by itself
    2021-03-01 14:53:44 CLIENT -> SERVER: Date: Mon, 1 Mar 2021 14:53:44 +0000
    2021-03-01 14:53:44 CLIENT -> SERVER: To: [email protected]
    2021-03-01 14:53:44 CLIENT -> SERVER: From: asdf <[email protected]>
    2021-03-01 14:53:44 CLIENT -> SERVER: Reply-To: asdf <[email protected]>
    2021-03-01 14:53:44 CLIENT -> SERVER: Subject: asdfasd
    2021-03-01 14:53:44 CLIENT -> SERVER: Message-ID: <[email protected]>
    2021-03-01 14:53:44 CLIENT -> SERVER: X-Mailer: PHPMailer 6.1.4 (https://github.com/PHPMailer/PHPMailer)
    2021-03-01 14:53:44 CLIENT -> SERVER: MIME-Version: 1.0
    2021-03-01 14:53:44 CLIENT -> SERVER: Content-Type: text/html; charset=UTF-8
    2021-03-01 14:53:44 CLIENT -> SERVER:
    2021-03-01 14:53:44 CLIENT -> SERVER: Name: asdf<br>
    2021-03-01 14:53:44 CLIENT -> SERVER: Phone: asdfasdf<br>
    2021-03-01 14:53:44 CLIENT -> SERVER: Email: [email protected]<br>
    2021-03-01 14:53:44 CLIENT -> SERVER: Subject: asdfasd<br>
    2021-03-01 14:53:44 CLIENT -> SERVER: Message: asdfasdf<br>
    2021-03-01 14:53:44 CLIENT -> SERVER:
    2021-03-01 14:53:44 CLIENT -> SERVER: .
    2021-03-01 14:53:44 SERVER -> CLIENT: 250 OK id=1lGjvc-00ATe5-7v
    2021-03-01 14:53:44 CLIENT -> SERVER: QUIT
    2021-03-01 14:53:44 SERVER -> CLIENT: 221 s66.rohost.com closing connection

    How should I solve this issue?
    Thanks


    #10036569
    umbrella
    Participant

    So, the idea is I received the message by email, but on the website page instead of getting the message “Message sent successful”, it is displayed all the info mentioned in my previous message.


    #10036584
    Support
    Keymaster

    Hello,

    You are receiving the message now, right ?

    So you just need change the variable $debug in the PHP file to $debug = 0;.

    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


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

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