27 lines
921 B
PHP
27 lines
921 B
PHP
<?php
|
|
require_once 'auth.php';
|
|
require_once '../mail/MailService.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
if (!is_logged_in() || !is_super_admin()) {
|
|
echo json_encode(['success' => false, 'error' => 'Unauthorized']);
|
|
exit;
|
|
}
|
|
|
|
$recipient = $_POST['recipient'] ?? '';
|
|
|
|
if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
|
|
echo json_encode(['success' => false, 'error' => 'Invalid recipient email address']);
|
|
exit;
|
|
}
|
|
|
|
$subject = "SMTP Test Email - CharityHub";
|
|
$htmlBody = "<h1>Test Successful!</h1><p>If you are reading this, your SMTP configuration is working correctly.</p><p>Sent at: " . date('Y-m-d H:i:s') . "</p>";
|
|
$textBody = "SMTP Test Email - CharityHub\n\nTest Successful!\nIf you are reading this, your SMTP configuration is working correctly.\nSent at: " . date('Y-m-d H:i:s');
|
|
|
|
$result = MailService::sendMail($recipient, $subject, $htmlBody, $textBody);
|
|
|
|
echo json_encode($result);
|
|
|