Email Notifications - bcgov/nr-compliance-enforcement GitHub Wiki
This system uses Common Hosted Email Service (CHES) provided by the Natural Resource Sector Common Services to send email notifications to users.
Links:
- Homepage: https://digital.gov.bc.ca/bcgov-common-components/common-hosted-email-service/
- Repo: https://github.com/bcgov/common-hosted-email-service
- API docs: https://ches.api.gov.bc.ca/api/v1/docs/
The following key-value pairs need to be added to your backend .env
file, and have been added to the secrets in OC accordingly. Request the sensitive values from a team member.
[email protected]
CHES_CLIENT_ID=<value>
CHES_CLIENT_SECRET=<value>
CHES_TOKEN_ENDPOINT=https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token
CHES_URI=https://ches-dev.api.gov.bc.ca
In the NatCom backend, a lightweight ches
module was made to house the calls to the external CHES API (for clarity, ches
refers to the NatCom backend module, and CHES refers to the hosted service). Since the CHES service can send emails from any @gov.bc.ca email address, no endpoints were created that accept a sender / receiver. The email
module holds the NatCom specific email logic including generating the email content, determining the sender and recipients, and producing any attachments. It then passes this to the ches
service to handle the external API call to CHES.
Note: sending the request to the CHES API does not guarantee that the email will be sent, it simply adds the request to the queue.
By default the email notifications are disabled via feature flag in the dev and test environments, and all email addresses stored in the database are set to the CEDS shared inbox. In order to test in one of these environments, you will need to manually enable the relevant feature flags in the database, and set the relevant email addresses accordingly.
To enable one of the email notification features, run the following with the appropriate feature code.
Be sure to set the feature flag back to false and reset the emails back to the appropriate values if necessary.
UPDATE public.feature_agency_xref
SET active_ind = 'Y'
WHERE feature_code = '<feature_code>';
where the relevant feature codes are:
-
REFEMAIL
for referral email notifications. When testing referral emails you may need to update the email addresses in the database. This can be done selectively (by zone shared inbox for COS and agency shared inbox for the other agencies) or as a blanket to set every email address in the system. To set all emails:
UPDATE public.email_reference
SET email_address = '[email protected]'
WHERE true;
to set selective emails, simply set the WHERE clause accordingly.
-
COLEMAIL
for collaborator email notifications. When testing collaborator emails, the recipient email address is fetched from their keycloak profile via the CSS service, so they cannot be blanketed as with referrals. Be sure to alert any users of the environment that you have enabled the flag so that they don't unknowingly send emails to production users while testing.