Test Email Notification System
This test script verifies that the Help Desk email notification system is working correctly.
Prerequisites
-
Ensure you have the required dependencies:
Terminal window cd scriptsnpm install node-fetch -
Make sure your Firebase Functions are running locally:
Terminal window cd functionsnpm run serve
Running the Test
Option 1: Test Against Local Functions (Recommended for Testing)
cd scriptsnode test-email-notification.jsOption 2: Test Against Production Functions
cd scriptsFUNCTIONS_URL=https://us-central1-your-project-id.cloudfunctions.net node test-email-notification.jsWhat the Test Does
-
Creates a test ticket in Firestore with:
- A test submitter email
- [email protected] as the person having the problem
- [email protected] also CC’d on the ticket
-
Sends a test notification email to [email protected] via the
/api/send-emailendpoint -
Cleans up by deleting the test ticket
Expected Result
You should receive an email at [email protected] with:
- Subject: “Re: Ticket #[ID] - Test Ticket for Email Notification”
- A formatted HTML email showing the test reply
- A link to view the ticket (though the ticket will be deleted by the time you click it)
Troubleshooting
If the email doesn’t arrive:
-
Check Functions logs for any errors:
Terminal window firebase functions:log -
Verify Mailgun configuration in your Functions environment:
- MAILGUN_API_KEY is set
- MAILGUN_DOMAIN is correct
- MAILGUN_FROM_EMAIL is valid
-
Check spam folder - test emails sometimes get filtered
-
Verify service account has proper permissions for Firestore
Alternative: Direct Mailgun Test
If you want to test Mailgun directly without going through the full system:
curl -s --user 'api:YOUR_MAILGUN_API_KEY' \ https://api.mailgun.net/v3/YOUR_DOMAIN/messages \ -F subject='Direct Mailgun Test' \ -F text='This is a direct test of Mailgun email delivery.'