# Dealer opportunity email and twice-daily reminder setup on Spaceship

Each newly assigned opportunity now sends one immediate email to the dealership's primary owner or manager. The assignment ID is used as an idempotency key, so processing the same job again does not send a duplicate notification.

The reminder process sends one summary email per dealership only when open assigned opportunities are still awaiting a submitted price. Email delivery is idempotent within each 12-hour window.

In cPanel, open **Cron Jobs** and add this command with the schedule set to twice per day:

```bash
/bin/bash -lc 'source /home/feszouuvxj/nodevenv/beatmycarquote-staging/22/bin/activate && cd /home/feszouuvxj/beatmycarquote-staging && npm run reminders:dealers >> /home/feszouuvxj/dealer-reminders.log 2>&1'
```

Suggested schedule:

```text
Minute: 0
Hour: 8,20
Day: *
Month: *
Weekday: *
```

The application environment must include `DATABASE_URL`, `RESEND_API_KEY`, `DEALER_FROM_EMAIL`, and `SITE_URL`. Test the task once from the application terminal with `npm run reminders:dealers` before enabling the cron schedule.

To verify accepted immediate notifications and reminders in Supabase, run:

```sql
select created_at, recipient_email, status, provider_message_id, idempotency_key, last_error
from email_deliveries
where idempotency_key like 'dealer-opportunity-%'
   or idempotency_key like 'dealer-reminder-%'
order by created_at desc
limit 100;
```

Immediate messages use an idempotency key beginning with `dealer-opportunity-`. Reminder summaries use `dealer-reminder-` and are limited to one per dealer in each 12-hour window.
