false, "errorMessage" => "Please fill all fields" ]; echo json_encode($response); } else { require '../../libs/PHPMailer/PHPMailer.php'; require '../../libs/PHPMailer/SMTP.php'; require '../../libs/PHPMailer/Exception.php'; $smtpAddress = $data["smtpaddress"]; $smtpPort = $data["smtpport"]; $smtpUsername = $data["smtpusername"]; $smtpPassword = $data["smtppassword"]; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = $smtpAddress; $mail->SMTPAuth = true; $mail->Username = $smtpUsername; $mail->Password = $smtpPassword; $mail->SMTPSecure = 'tls'; $mail->Port = $smtpPort; $getUser = "SELECT * FROM user WHERE id = 1"; $user = $db->querySingle($getUser, true); $email = $user['email']; $name = $user['username']; $mail->setFrom('wallos@wallosapp.com', 'Wallos App'); $mail->addAddress($email, $name); $mail->Subject = 'Wallos Notification'; $mail->Body = 'This is a test notification. If you\'re seeing this, the configuration is correct.'; if ($mail->send()) { $response = [ "success" => true, ]; echo json_encode($response); } else { $response = [ "success" => false, "errorMessage" => "Error sending email." . $mail->ErrorInfo ]; echo json_encode($response); } } } ?>