Не отправляется HTML-форма с сайта - ошибка 500;
Кроме того, В консоли...
adaptive.js:125 { readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …} error
Может быть это из-за...
Неустранимая ошибка PHP: require (): Не удалось открыть 'home / homexnmx / vendor / autoload.php' (include_path = '.: / Opt / alt / php72 / usr / share / pear') в / home / homexnmx / public_html / tmp_name / submit.php в строке 20
Пути на хостинге... /home/homexnmx/vendor/autoload.php Папка vendor состоит из папок:
- composer с файлами внутри;
- phpmailer / phpmailer с папками и файлами внутри;
- autoload.php
/home/homexnmx/composer.json
/home/homexnmx/composer.lock
/home/homexnmx/public_html/composer.phar
/home/homexnmx/public_html/php.ini
/home/homexnmx/public_html/tmp_name/uploads (uploads - для загрузки файлов из формы)
/home/homexnmx/public_html/tmp_name/submit.php (submit.php - обработчик HTML-формы)
/home/homexnmx/public_html/php/httpd.conf (php_value include_path ".:/opt/alt/php72/usr/share/pear";)
Код обработчика (submit.php)...
use PHPMailer\PHPMailer\PHPMailer; // создайте класс PHPMailer
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//require 'vendor/autoload.php'; // при использовании Composer
//require './../vendor/autoload.php'; // при использовании Composer
require 'home/homexnmx/vendor/autoload.php'; (всё это перепробовал)
function sendmail($to, $nameto, $subject, $message, $altmess) {
$mail = new PHPMailer(); // создание нового объекта PHPMailer
$mail->SMTPDebug = 0;
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = $from;
$mail->Password = "xxxxxxxx"; //отправителя
$mail->SMTPSecure = "ssl";
$from = "отправитель@gmail.com";
$namefrom = "WebBuilding"; // имя отправителя
$mail->setFrom($from, $namefrom);
$mail->addCC($from, $namefrom);
$subject = 'Из формы модального окна';
$mail->Subject = $subject;
$mail->isHTML();
$message = "Имя: ".$_POST['user_name']."\r\nEmail: ".$from."\r\nWebsite: ".$_POST['user_website']."\r\nPhone: ".$_POST['user_phone']."\r\nIP: ".$_SERVER['REMOTE_ADDR']."\r\n\r\n Сообщение:\r\n\r\n ".$_POST['user_comment'];
$mail->Body = $message;
$altmess = $_FILES['userfile']['name'];
$mail->AltBody = $altmess;
$to = 'получатель@mail.com';
$nameto = 'Owen';
$mail->addAddress($to, $nameto);
return $mail->send();
}
var resalt = document.querySelector('.resalt');
$("#modal-form").submit(function(e){
e.preventDefault();
if(document.getElementById('modal-form').user_name.value == '' || document.getElementById('modal-form').user_email.value == '' || document.getElementById('modal-form').user_website.value == '' || document.getElementById('modal-form').user_phone.value == ''){
valid = false;
return valid;
}
$.ajax({
type: "POST",
url: "https://site.com/tmp_name/submit.php",
data: $(this).serialize(),
success: function(data){
resalt = '<b>JS Your message sent!</b>';
$('.block-popup').hide('');
$('.note').css('display', 'block');
$('.resalt').html(data);
},
error: function(jqXHR, exception) {
console.log(jqXHR);
console.log(exception);
resalt = 'Mailer Error';
$('.block-popup').hide('');
$('.note').css('display', 'block');
$('.resalt').html(data);
}
});
return;
});
<form action="https://site.com/tmp_name/submit.php" method="POST" id="modal-form" name="feedback_form" class="contact_form" enctype="multipart/form-data">
<ul>
<li>
<h2>Contact Us</h2>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label>Name:</label>
<input type="text" name="user_name" placeholder="Username" required pattern="[A-z, А-я]{1,15}" id="name" />
<span class="form_hint">"Text"</span>
</li>
<li>
<label>Email:</label>
<input type="email" name="user_email" placeholder="[email protected]" required id="email" />
<span class="form_hint">"[email protected]"</span>
</li>
<li>
<label>Website:</label>
<input type="url" name="user_website" placeholder="http://raidgir.com" required pattern="(http|https)://.+" id="website" />
<span class="form_hint">"http://example.com"</span>
</li>
<li>
<label>Phone:</label>
<input type="tel" name="user_phone" placeholder="+1 212 123 45 67" required pattern="^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$" id="phone" />
<span class="form_hint">"+1 212 123 45 67"</span>
</li>
<li>
<label>File:</label>
<input type="hidden" name="max_file_size" value="10000000" />
<input type="file" name="userfile[]" value="1" class="upload_files" multiple="multiple" />
</li>
<li>
<label>Message:</label>
<textarea name="user_comment" cols="40" rows="6" required pattern="[A-z, А-я, 0-9]{1,15}" id="message"></textarea>
<span class="form_hint mes">"Text"</span>
</li>
</ul>
<button type="submit" id="btnSend" name="sendMail" class="submit">Submit Form</button>
</form>
Может кто подскажет, в чём может быть проблема? Composer загрузил по инструкции хостера, так же и PHPMailer.