My website is PHP website. My website is working well with localhost. Ngrok sever is too no problem, but I deployed it in dash.infinity.com. Of course, there is not any mistake, but website is not working well. I used resend API as email API, it occurred internal server error 500. Please help me. My code is following. This is ajax part.
function finish_exam() {
$("#ring").addClass("ring");
$("#ring").html('Saving');
$("#loading").addClass("loading");
$('body').css('background-color', '#959566');
// var question_array = [];
// console.log(q.length);
// console.log(q)
// console.log(question_array);
// console.log(question_array);
// console.log(data);
$.post('test_insert.php', {
email: "<?= $email ?>",
title_arr: array2json(title_arr),
answer_arr: array2json(answer_arr),
q: array2json(q),
name_arr: array2json(name_arr),
all_answer_arr: array2json(all_answer_arr),
question_type: array2json(question_type),
// data: data
},
function (returnedData) {
if (returnedData) {
console.log(returnedData);
let answer = JSON.parse(returnedData);
if(answer.flag == "success") {
exam_number = answer.exam_no;
$("#ring").removeClass("ring");
$("#ring").html('');
$("#loading").removeClass("loading");
$('body').css('background-color', '#ffffcc');
// $("#export_btn").removeAttr('disabled');
$.post('gmail_api.php', {
email:"<?= $email ?>"
}, function (returnedData) {
if(returnedData) {
console.log(returnedData)
alert("Survey completed, no further action is necessary on your part.");
}
} )
}
}
}).fail(function () {
console.log("error");
});
}
This is PHP part:
<?php
require_once 'vendor/autoload.php';
$email = $_REQUEST['email'];
try {
// Initialize the Resend client
$resend = Resend::client('re_SN6U9cej_iLHNvbmjwgGCQEjyCQqiKtsL');
// Prepare the email data
$emailData = [
'from' => 'Survey Notification <[email protected]>',
'to' => ['[email protected]'],
'subject' => 'Survey project notification',
'text' => $email . ' sucessfully completed their survey.',
'attachments' => [
// [
// 'filename' => 'invoice.pdf',
// 'content' => $invoiceBuffer
// ]
],
'headers' => [
// 'X-Entity-Ref-ID' => '123456789',
],
'tags' => [
// [
// 'name' => 'category',
// 'value' => 'confirm_email',
// ],
],
];
// Send the email
$resend->emails->send($emailData);
echo "success";
} catch (Exception $e) {
echo "An error occurred: " . $e->getMessage();
}
?>
As I know, code is no problem. I think Resend API server is not accept my domain. How to solve it? Or Is there other email API without error when deploy my web site?
500 internal service error
I found the reason. My php website is supported php version 8.2. But my hosting site is supported the php version 7.4. There is a reason. Thank you for your time.