47 أسطر
1.3 KiB
TypeScript
47 أسطر
1.3 KiB
TypeScript
// debug-resend.js
|
|
require('dotenv').config();
|
|
const { Resend } = require('resend');
|
|
|
|
console.log('🔍 Debugging Resend...');
|
|
|
|
// Check environment
|
|
console.log('RESEND_API_KEY exists:', !!process.env.RESEND_API_KEY);
|
|
console.log('RESEND_API_KEY starts with:', process.env.RESEND_API_KEY ? process.env.RESEND_API_KEY.substring(0, 3) : 'N/A');
|
|
console.log('FROM_EMAIL:', process.env.FROM_EMAIL);
|
|
|
|
if (!process.env.RESEND_API_KEY) {
|
|
console.log('❌ RESEND_API_KEY is missing!');
|
|
process.exit(1);
|
|
}
|
|
|
|
const resend = new Resend(process.env.RESEND_API_KEY);
|
|
|
|
async function test() {
|
|
try {
|
|
console.log('\n🚀 Testing Resend API...');
|
|
|
|
const { data, error } = await resend.emails.send({
|
|
from: process.env.FROM_EMAIL || 'myDrive <onboarding@resend.dev>',
|
|
to: 'hamodeh.mnzk@gmail.com',
|
|
subject: 'Resend Test',
|
|
text: 'This is a test email from Resend.',
|
|
});
|
|
|
|
if (error) {
|
|
console.log('❌ Resend API Error:');
|
|
console.log('Error name:', error.name);
|
|
console.log('Error message:', error.message);
|
|
console.log('Error status:', error.statusCode);
|
|
return;
|
|
}
|
|
|
|
console.log('✅ Email sent!');
|
|
console.log('Email ID:', data.id);
|
|
|
|
} catch (err) {
|
|
console.log('❌ Unexpected error:');
|
|
console.log(err.message);
|
|
}
|
|
}
|
|
|
|
test(); |