- This topic has 6 replies, 2 voices, and was last updated 5 years, 7 months ago by
Support. This post has been viewed 1537 times
-
AuthorPosts
-
November 27, 2020 at 3:35 am #10035220
markusweb
ParticipantHello, 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-corporate5November 27, 2020 at 6:40 am #10035222Support
KeymasterHello,
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.phpError 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.phpyou 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
November 27, 2020 at 10:29 am #10035226markusweb
ParticipantHello. 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);
}
November 27, 2020 at 11:30 am #10035227markusweb
ParticipantI believe it is something weird since I can’t get the mailchimp newsletter to work either. Everything else works properly!
Thanks in advance!
November 27, 2020 at 11:22 pm #10035232Support
KeymasterHello,
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.phpAnd 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
November 28, 2020 at 12:00 am #10035236markusweb
ParticipantIt turned out to be an issue on the severs end!
November 28, 2020 at 1:01 am #10035238Support
KeymasterHello 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
-
AuthorPosts
This topic is marked as "RESOLVED" and can not rceive new replies.