<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

// Include manually uploaded PHPMailer classes
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
require 'phpmailer/Exception.php';

function sendResetLink($to, $resetLink) {
    $mail = new PHPMailer(true);
    
    try {
        // SMTP settings
        $mail->isSMTP();
        $mail->Host = 'mail.gobolchain.com';   // Your SMTP server (check with your hosting provider)
        $mail->SMTPAuth = true;
        $mail->Username = 'team@gobolchain.com';
        $mail->Password = '@Jibala1997';  // use your actual email password or app-specific password
        $mail->SMTPSecure = 'ssl'; // or 'ssl' depending on your host
        $mail->Port = 465;         // or 465 for SSL

        // Email content
        $mail->setFrom('team@gobolchain.com', 'Gobolchain Support');
        $mail->addAddress($to);
        $mail->isHTML(true);
        $mail->Subject = 'Reset Your Gobolchain Password';

        $mail->Body = "
            <h2>Gobolchain Password Reset</h2>
            <p>You recently requested a password reset.</p>
            <p><strong>Click the button below to reset your password:</strong></p>
            <a href='$resetLink' style='display: inline-block; padding: 10px 20px; background-color: #c70000; color: white; border-radius: 5px; text-decoration: none;'>Reset Password</a>
            <p>If you didn't request this, you can ignore this email.</p>
            <hr>
            <small>This link will expire in 1 hour. Do not share this email with anyone.</small>
        ";

        $mail->send();
        return true;

    } catch (Exception $e) {
        error_log("Mailer Error: {$mail->ErrorInfo}");
        return false;
    }
}
?>