Ошибка при отправке письма на почту VueJS
у меня такой вопрос. В общем, делаю форму на vuejs. Не получается отправить данные на почту. Отправляю с помощью axios и phpmailer, на сервере выдает ошибку http://мойхост/sendmail.php 500 (Internal Server Error)
async submitHandler() {
if (this.$v.$invalid) {
this.$v.$touch()
return
}
axios.post('sendmail.php', {
'limit' : this.limit,
'email' : this.email
})
.then(function(res){
console.log(res)
})
.catch(function(error){
console.log(error)
})
}
}
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';
$mail->setLanguage('ru', 'phpmailer/language/');
$mail->IsHTML(true);
$mail->setFrom('[email protected]', '');
$mail->addAddress('[email protected]');
$mail->Subject = 'Тема';
if(trim(!empty($_POST['name']))){
$body.='<p><strong>Limit:</strong>'.$_POST['limit'].'</p>';
}
if(trim(!empty($_POST['email']))){
$body.='<p><strong>Email:</strong>'.$_POST['email'].'</p>';
}
$mail->Body = $body;
if(!$mail->send()){
$message = 'error';
} else {
$message = 'all right';
}
$response = ['message' => $message];
header('Content-type: application/json');
echo json_encode($response);
?>