- Add PrayerChain component for visualizing linked prayers - Add SharePrayer component with social media integration (Twitter, Facebook, WhatsApp, copy link) - Create /testimonies page for public answered prayer stories - Update Firestore rules for public testimony access - Enhance Organization tab with prayer chains - Add Testimonies navigation tab - Fix Firebase Admin SDK integration for server-side operations - Improve email system with proper server-side authentication - Update prayer form to handle optional fields correctly - Deploy updated Firestore security rules
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
// Test script to send an email using your configured SMTP settings
|
|
// Run with: node test-email.js [email-address]
|
|
|
|
import fetch from 'node-fetch';
|
|
|
|
const testEmail = async (testEmailAddress) => {
|
|
// Use provided email or default
|
|
const email = testEmailAddress || 'nate.emmert@necloud.us';
|
|
|
|
const payload = {
|
|
email: email,
|
|
subject: 'Test Email from Prayer App',
|
|
message: `Hello!
|
|
|
|
This is a test email from your Prayer App.
|
|
|
|
Test Details:
|
|
- Type: Test Email
|
|
- Date: ${new Date().toLocaleDateString()}
|
|
- Time: ${new Date().toLocaleTimeString()}
|
|
- Test Email: ${email}
|
|
|
|
If you received this email, your SMTP settings are configured correctly!`
|
|
};
|
|
|
|
console.log('📧 Sending test email to:', payload.email);
|
|
console.log('📧 Subject:', payload.subject);
|
|
|
|
try {
|
|
const response = await fetch('http://localhost:3000/api/send-email', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(payload),
|
|
});
|
|
|
|
const responseText = await response.text();
|
|
console.log('📧 Response status:', response.status);
|
|
|
|
if (response.ok) {
|
|
console.log('✅ Email sent successfully!');
|
|
console.log('📧 Response:', responseText);
|
|
} else {
|
|
console.error('❌ Failed to send email');
|
|
console.error('📧 Response:', responseText);
|
|
|
|
// Try to parse as JSON for better error messages
|
|
try {
|
|
const errorData = JSON.parse(responseText);
|
|
if (errorData.error) {
|
|
console.error('📧 Error details:', errorData.error);
|
|
|
|
if (errorData.error.includes('SMTP configuration not found')) {
|
|
console.log('\n💡 Solution: Run "node setup-smtp.js" to configure SMTP settings');
|
|
}
|
|
}
|
|
} catch (parseError) {
|
|
// Response wasn't JSON, already logged above
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error('❌ Error sending email:', error.message);
|
|
}
|
|
};
|
|
|
|
// Get email from command line argument or use default
|
|
const emailArg = process.argv[2];
|
|
testEmail(emailArg); |