<?php
function send() {
    $name = trim($_POST['name'] ?? '');
    $email = trim($_POST['email'] ?? '');
    $msg = trim($_POST['msg'] ?? '');
    
    if (empty($name) || empty($email) || empty($msg)) {
        error_response('Please fill in all fields.');
    }
    
    require_once __DIR__ . '/../config/mail.php';
    try {
        $mail = make_mailer('info@host25cent.com', 'Host25Cent', 'info@host25cent.com');
        $mail->AddAddress('berlikplc@gmail.com');
        $mail->Subject = "Contact from $name";
        $mail->MsgHTML("<p><strong>Name:</strong> $name</p><p><strong>Email:</strong> $email</p><p><strong>Message:</strong><br>$msg</p>");
        $mail->Send();
        success_response([], 'Message sent successfully.');
    } catch (Exception $e) {
        error_response('Failed to send message.');
    }
}