feat: Add email settings management and templates functionality
- Implemented email settings configuration in the admin panel, allowing for SMTP settings and notification preferences. - Created a new template for email settings with fields for SMTP host, port, username, password, sender address, and recipients. - Added JavaScript functionality to handle loading, saving, and validating email settings. - Introduced email templates management, enabling the listing, editing, and saving of email templates. - Updated navigation to include links to email settings and templates. - Added tests for email settings and templates to ensure proper functionality and validation.
This commit is contained in:
30
README.md
30
README.md
@@ -28,6 +28,7 @@ Backend service for a static website. The app accepts contact and newsletter sub
|
||||
- [Health Checks and Monitoring](#health-checks-and-monitoring)
|
||||
- [Testing](#testing)
|
||||
- [Deployment Notes](#deployment-notes)
|
||||
- [Admin Email Settings](#admin-email-settings)
|
||||
- [Email Templates](#email-templates)
|
||||
|
||||
## Overview
|
||||
@@ -208,15 +209,17 @@ When `POSTGRES_URL` is set and `psycopg2-binary` is available, the app prefers P
|
||||
|
||||
### Email delivery
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ----------------- | ----------------------------------------------------------------------- | -------- |
|
||||
| `SMTP_HOST` | SMTP server hostname or IP. Leave empty to disable email notifications. | _(none)_ |
|
||||
| `SMTP_PORT` | SMTP server port. | `587` |
|
||||
| `SMTP_USERNAME` | Username for SMTP authentication. | _(none)_ |
|
||||
| `SMTP_PASSWORD` | Password or token for SMTP authentication. | _(none)_ |
|
||||
| `SMTP_SENDER` | Sender email address; defaults to `SMTP_USERNAME` when unset. | _(none)_ |
|
||||
| `SMTP_RECIPIENTS` | Comma-separated recipient list for notifications. | _(none)_ |
|
||||
| `SMTP_USE_TLS` | Enables STARTTLS when `true`. | `true` |
|
||||
| Variable | Description | Default |
|
||||
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------- |
|
||||
| `SMTP_HOST` | SMTP server hostname or IP. Leave empty to disable email notifications. | _(none)_ |
|
||||
| `SMTP_PORT` | SMTP server port. | `587` |
|
||||
| `SMTP_USERNAME` | Username for SMTP authentication. | _(none)_ |
|
||||
| `SMTP_PASSWORD` | Password or token for SMTP authentication. | _(none)_ |
|
||||
| `SMTP_SENDER` | Sender email address; defaults to `SMTP_USERNAME` when unset. | _(none)_ |
|
||||
| `SMTP_RECIPIENTS` | Comma-separated recipient list for notifications. | _(none)_ |
|
||||
| `SMTP_USE_TLS` | Enables STARTTLS when `true`. | `true` |
|
||||
| `EMAIL_NOTIFY_CONTACT_FORM` | Default toggle for sending emails when new contact submissions arrive. Can be overridden in the admin UI. | `true` |
|
||||
| `EMAIL_NOTIFY_NEWSLETTER_SIGNUPS` | Default toggle for sending notification/confirmation emails when new newsletter signups occur. Admin UI can override per deployment. | `false` |
|
||||
|
||||
### Rate limiting and caching
|
||||
|
||||
@@ -268,9 +271,16 @@ SMTP integration tests are skipped unless `RUN_SMTP_INTEGRATION_TEST=1` and vali
|
||||
- Import or mirror the required reusable actions (`actions/checkout`, `actions/setup-python`, and the Docker actions) into your Gitea instance so that the workflow can resolve them.
|
||||
- For production use, deploy the container behind a load balancer or reverse proxy and supply the appropriate environment variables.
|
||||
|
||||
## Admin Email Settings
|
||||
|
||||
- Navigate to `/admin/email-settings` after authenticating to manage SMTP host, credentials, sender identity, notification recipients, and feature toggles.
|
||||
- Values saved through the form are persisted in the `app_settings` table and override any `.env` defaults until updated again.
|
||||
- The page surfaces validation feedback in-line and falls back to environment-sourced defaults when a field is left blank.
|
||||
- Toggle `Email notifications for new contact submissions` and `Confirmation emails for newsletter signups` to control runtime behaviour. These switches seed from `EMAIL_NOTIFY_CONTACT_FORM` and `EMAIL_NOTIFY_NEWSLETTER_SIGNUPS` respectively.
|
||||
|
||||
## Email Templates
|
||||
|
||||
The application supports customizable email templates for newsletter confirmations. The confirmation email template can be edited through the admin settings page under the dynamic settings management. The template uses HTML format and should include an unsubscribe link for compliance with email regulations.
|
||||
The application supports customizable email templates for newsletter confirmations. Administrators can manage templates from the dedicated **Email Templates** page (`/admin/email-templates`), which provides a list/detail editor for each available template. Changes are persisted to dynamic settings, allowing runtime updates without redeploying the application. Templates use HTML format and should include an unsubscribe link for compliance with email regulations.
|
||||
|
||||
Default confirmation email includes:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user