fix(erpnext): self-heal outgoing Email Account password from SMTP_* env

Root cause of recurring 'Password not found for Email Account Performance West
Outgoing': the account was shipped as a fixture with awaiting_password=1 and no
password. Email Account SMTP passwords are encrypted per-site and cannot live in
a fixture, so every `bench migrate` reimported the fixture and re-broke
outgoing mail (login notifications, password resets, welcome emails).

- Remove the Email Account fixture (it cannot carry the encrypted secret).
- Add email_account_sync.sync_outgoing_password: idempotent, exception-safe
  upsert that reconciles the account + password from SMTP_* env and clears
  awaiting_password.
- Wire it to after_migrate (repairs at end of every deploy/migrate, right after
  fixtures import) and the daily scheduler (heals out-of-band restore/restart
  drift).
- Pass SMTP_* into the erpnext + erpnext-scheduler containers so the sync has
  the secret (they previously had no SMTP env).
This commit is contained in:
justin 2026-06-17 09:48:16 -05:00
parent 1eb29f80be
commit 557b45f65d
4 changed files with 161 additions and 21 deletions

View file

@ -183,6 +183,14 @@ services:
# shows "Link invalid" and the portal Compliance section is empty.
- CUSTOMER_JWT_SECRET=${CUSTOMER_JWT_SECRET}
- DATABASE_URL=postgresql://pw:${DB_PASSWORD:-pw_dev_2026}@api-postgres:5432/performancewest
# Outgoing mail: the "Performance West Outgoing" Email Account password is
# reconciled from these on `bench migrate` (after_migrate hook), so the
# account can never be left with awaiting_password=1 / empty password.
- SMTP_HOST=${SMTP_HOST}
- SMTP_PORT=${SMTP_PORT}
- SMTP_USER=${SMTP_USER}
- SMTP_PASS=${SMTP_PASS}
- SMTP_FROM=${SMTP_FROM}
volumes:
- erpnext-frappe-public:/home/frappe/frappe-bench/apps/frappe/frappe/public
- erpnext-erpnext-public:/home/frappe/frappe-bench/apps/erpnext/erpnext/public
@ -219,6 +227,14 @@ services:
- REDIS_CACHE=redis://erpnext-redis:6379/0
- REDIS_QUEUE=redis://erpnext-redis:6379/1
- REDIS_SOCKETIO=redis://erpnext-redis:6379/2
# Daily scheduler self-heals the outgoing Email Account password from these
# (email_account_sync.sync_outgoing_password), covering drift from
# out-of-band restarts / DB restores.
- SMTP_HOST=${SMTP_HOST}
- SMTP_PORT=${SMTP_PORT}
- SMTP_USER=${SMTP_USER}
- SMTP_PASS=${SMTP_PASS}
- SMTP_FROM=${SMTP_FROM}
depends_on:
- erpnext-mariadb
- erpnext-redis