// 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);