-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-email.js
More file actions
37 lines (32 loc) · 1.08 KB
/
Copy pathtest-email.js
File metadata and controls
37 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { sendOrderConfirmation } = require('./backend/emailService');
// Test order data
const testOrder = {
orderId: 'TEST' + Date.now().toString().slice(-6),
customerName: 'Test Customer',
deliveryAddress: '123 Test St, Test City',
phone: '+91 9876543210',
items: [
{ id: 1, name: 'Chocolate Cake', quantity: 2, price: 350 },
{ id: 2, name: 'Vanilla Muffin', quantity: 3, price: 50 }
],
subtotal: 850,
tax: 42.50,
delivery: 50,
total: 942.50,
orderDate: new Date().toISOString()
};
require('dotenv').config({ path: './.env' });
// Use the email from environment variables or default to a test email
const testEmail = process.env.EMAIL_FROM || 'test@example.com';
console.log('Starting email test...');
console.log('Sending test email to:', testEmail);
sendOrderConfirmation(testOrder, testEmail)
.then(result => {
console.log('Email sent successfully!', result);
process.exit(0);
})
.catch(error => {
console.error('Failed to send email:');
console.error(error);
process.exit(1);
});