#!/usr/bin/env node /** * Test Geofence Email Notification * * This script sends a test email notification for a geofence event * without needing the full MQTT/Next.js server stack. */ const nodemailer = require('nodemailer'); const { render } = require('@react-email/components'); console.log('π§ Geofence Email Notification Test\n'); // SMTP configuration from .env const SMTP_CONFIG = { host: process.env.SMTP_HOST || 'smtp-relay.brevo.com', port: parseInt(process.env.SMTP_PORT || '587', 10), secure: process.env.SMTP_SECURE === 'true', auth: { user: process.env.SMTP_USER || 'joachim.hummel@gmail.com', pass: process.env.SMTP_PASS || 'xqwXW2Sr3ZNcITa1', }, }; const FROM_EMAIL = process.env.SMTP_FROM_EMAIL || 'noreply@businesshelpdesk.biz.com'; const FROM_NAME = process.env.SMTP_FROM_NAME || 'Location Tracker'; const TO_EMAIL = 'joachim.hummel@gmail.com'; async function sendTestEmail() { try { console.log('π§ Step 1: Creating SMTP transporter...'); console.log(` Host: ${SMTP_CONFIG.host}:${SMTP_CONFIG.port}`); console.log(` From: ${FROM_NAME} <${FROM_EMAIL}>`); console.log(` To: ${TO_EMAIL}\n`); const transporter = nodemailer.createTransport(SMTP_CONFIG); // Test connection console.log('π Step 2: Testing SMTP connection...'); await transporter.verify(); console.log('β SMTP connection successful!\n'); // Prepare email content console.log('π Step 3: Preparing email...'); const emailData = { username: 'Admin', deviceName: 'Device A', geofenceName: 'Test Zone', timestamp: new Date().toISOString(), latitude: 50.1109, longitude: 8.6821, distanceFromCenter: 0, }; // Simple HTML email (since we can't easily import React Email in this context) const html = `