📧 Complete Email Flow Explanation

Here's exactly how each email flow works in your system:

📊 Summary Table

Email Type
Trigger
Recipient
Default Status
Purpose
<span style="color: var(--vscode-textLink-foreground)">new-invoice-job</span>
Job created with invoice plan
<strong>Your team</strong>
✅ Enabled
Internal operations
<span style="color: var(--vscode-textLink-foreground)">job-activated</span>
Job status changed to active
<strong>Job poster</strong>
❌ Disabled
Job poster notification
<span style="color: var(--vscode-textLink-foreground)">job-expired</span>
Cron job
<strong>Job poster</strong>
❌ Disabled
Job poster notification
<span style="color: var(--vscode-textLink-foreground)">job-application-received</span>
Someone applies to job
<strong>Job poster</strong>
❌ Disabled
Job poster notification

1. 🆕 NEW INVOICE JOB (new-invoice-job)

When it triggers:

When someone creates a job and selects a plan that requires invoice payment

Triggered in /api/jobs/add-job/route.ts when isInvoice = true

Who receives it:

Your internal team (notification emails)

recipient_type = 'notification'

Sends to emails in notification_emails array

Purpose:

Notifies your team that a new job needs invoice processing

Includes job details and pricing plan info

Template enabled by default:

✅ YES - This is enabled by default since it's for your operations

2. ✅ JOB ACTIVATED (job-activated)

When it triggers:

When an admin/user changes a job status from draft to active

Who receives it:

Job poster (person who created the job)

Sends to the email of the user who posted the job

Purpose:

Notifies job poster that their job is now live and visible to candidates

Includes job details and expiration date

Template enabled by default:

❌ NO - Disabled by default, organizations can enable it

3. ⏰ JOB EXPIRED (job-expired)

When it triggers:

Automated cron job

Processes jobs that expired in the last 24 hours

Who receives it:

Job poster (person who created the job)

Sends to the email of the user who posted the job

Purpose:

Notifies job poster that their job has expired and is no longer visible

Includes job details and suggests reposting

Template enabled by default:

❌ NO - Disabled by default, organizations can enable it

4. 📝 JOB APPLICATION RECEIVED (job-application-received)

When it triggers:

When someone submits a job application

Who receives it:

Job poster (person who created the job)

Sends to the email of the user who posted the job

Purpose:

Notifies job poster that someone applied to their job

Includes applicant details (name, email)

Template enabled by default:

❌ NO - Disabled by default, organizations can enable it

🎯 Key Points:

Only new-invoice-job goes to your team - all others go to job posters

Only new-invoice-job is enabled by default - others must be enabled per organization

All job poster emails use the organization name as sender when possible

All templates are customizable per organization through the dashboard

Email failures don't break the main processes (job creation, application submission, etc.)

This system gives organizations full control over which notifications they want to receive while ensuring your team gets the operational emails they need!