Files
meet-hub/debug-email.sh
dwindown 08e56a22d8 Fix send-auth-otp: Remove notification_logs references
- Remove notification_logs table references (table doesn't exist)
- This was causing the function to crash after sending email
- Now the function should complete successfully
- Added better email payload logging
- Keep .env file for local development
2026-01-02 15:07:41 +07:00

92 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Test script to debug email sending issue
# Run this after registering a user
echo "🔍 OTP Email Debug Script"
echo "==========================="
echo ""
SUPABASE_URL="https://lovable.backoffice.biz.id"
SERVICE_KEY="YOUR_SERVICE_ROLE_KEY_HERE" # Replace with actual service role key
echo "1. Checking recent OTP records..."
echo "Run this in Supabase SQL Editor:"
echo ""
echo "SELECT"
echo " id,"
echo " user_id,"
echo " email,"
echo " otp_code,"
echo " expires_at,"
echo " used_at,"
echo " created_at"
echo "FROM auth_otps"
echo "ORDER BY created_at DESC"
echo "LIMIT 1;"
echo ""
echo "2. Checking notification logs..."
echo "Run this in Supabase SQL Editor:"
echo ""
echo "SELECT"
echo " id,"
echo " user_id,"
echo " email,"
echo " notification_type,"
echo " status,"
echo " provider,"
echo " error_message,"
echo " created_at"
echo "FROM notification_logs"
echo "WHERE notification_type = 'auth_email_verification'"
echo "ORDER BY created_at DESC"
echo "LIMIT 5;"
echo ""
echo "3. Checking notification settings..."
echo "Run this in Supabase SQL Editor:"
echo ""
echo "SELECT"
echo " platform_name,"
echo " from_name,"
echo " from_email,"
echo " api_token,"
echo " mailketing_api_token"
echo "FROM notification_settings"
echo "LIMIT 1;"
echo ""
echo "4. Checking email template..."
echo "Run this in Supabase SQL Editor:"
echo ""
echo "SELECT"
echo " key,"
echo " name,"
echo " is_active,"
echo " email_subject,"
echo " LEFT(email_body_html, 200) as email_preview"
echo "FROM notification_templates"
echo "WHERE key = 'auth_email_verification';"
echo ""
echo "5. Testing email sending manually..."
echo "Replace USER_ID and EMAIL with actual values from step 1, then run:"
echo ""
echo "curl -X POST ${SUPABASE_URL}/functions/v1/send-auth-otp \\"
echo " -H \"Authorization: Bearer ${SERVICE_KEY}\" \\"
echo " -H \"Content-Type: application/json\" \\"
echo " -d '{"
echo " \"user_id\": \"USER_UUID\","
echo " \"email\": \"your@email.com\""
echo " }'"
echo ""
echo "6. Common issues to check:"
echo " ✓ from_email is not 'noreply@example.com' (set real domain)"
echo " ✓ api_token or mailketing_api_token is set"
echo " ✓ Email template is_active = true"
echo " ✓ Mailketing API is accessible from Supabase server"
echo " ✓ Check notification_logs.error_message for specific error"
echo ""