Skip to content

Commit 340199c

Browse files
Add documentation for config of relay service and Django app (#37)
* first draft of configuration docs * add missing ending code block characters * add space before code block ticky-tack, but it bothers me so 🤷♂️ * add quotes and change conn age to correct name * remove `EMAIL_BACKEND` from config docs
1 parent 15e3154 commit 340199c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,65 @@ DATABASE_ROUTERS = [
111111

112112
## Configuration
113113

114+
### Relay Service
115+
116+
Configuration of the relay service differs depending on whether you are using the provided Docker image or the management command within a Django project.
117+
118+
#### Docker
119+
120+
When running the relay service using Docker, config values are set via environment variables. The names of the environment variables are the same as the Django settings, e.g. to set `DEBUG` to `True`, you would set `-e "DEBUG=True"` when running the container.
121+
122+
For settings that are dictionaries, a `__` is used to separate the keys, e.g. to set `DATABASES["default"]["CONN_MAX_AGE"]` to `600` or 10 minutes, you would set `-e "DATABASES__default__CONN_MAX_AGE=600"`.
123+
124+
#### Django
125+
126+
When running the relay service from a Django project, config values are read from the Django settings for that project.
127+
128+
### Django App
129+
130+
Configuration of the Django app is done through the `DJANGO_EMAIL_RELAY` dictionary in your Django settings. All settings are optional. Here is an example configuration, with the default values shown:
131+
132+
```python
133+
DJANGO_EMAIL_RELAY = {
134+
"DATABASE_ALIAS": email_relay.conf.EMAIL_RELAY_DATABASE_ALIAS, # "email_relay_db"
135+
"EMAIL_MAX_BATCH": None,
136+
"EMAIL_MAX_DEFERRED": None,
137+
"EMAIL_MAX_RETRIES": None,
138+
"EMPTY_QUEUE_SLEEP": 30,
139+
"EMAIL_THROTTLE": 0,
140+
"MESSAGES_BATCH_SIZE": None,
141+
}
142+
```
143+
144+
#### `DATABASE_ALIAS`
145+
146+
The database alias to use for the email relay database. This must match the database alias used in your `DATABASES` setting. A default is provided at `email_relay.conf.EMAIL_RELAY_DATABASE_ALIAS`. You should only need to set this if you are using a different database alias.
147+
148+
#### `EMAIL_MAX_BATCH`
149+
150+
The maximum number of emails to send in a single batch. The default is `None`, which means there is no limit.
151+
152+
#### `EMAIL_MAX_DEFERRED`
153+
154+
The maximum number of emails that can be deferred before the relay service stops sending emails. The default is `None`, which means there is no limit.
155+
156+
157+
#### `EMAIL_MAX_RETRIES`
158+
159+
The maximum number of times an email can be deferred before being marked as failed. The default is `None`, which means there is no limit.
160+
161+
#### `EMPTY_QUEUE_SLEEP`
162+
163+
The time in seconds to wait before checking the queue for new emails to send. The default is `30` seconds.
164+
165+
#### `EMAIL_THROTTLE`
166+
167+
The time in seconds to sleep between sending emails, to avoid potential rate limits or overloading your SMTP server. The default is `0` seconds.
168+
169+
#### `MESSAGES_BATCH_SIZE`
170+
171+
The batch size to use when bulk creating `Messages` in the database. The default is `None`, which means Django's default batch size will be used.
172+
114173
## Inspiration
115174

116175
This package is heavily inspired by the [`django-mailer`](https://github.com/pinax/django-mailer) package. `django-mailer` is licensed under the MIT license, which is also the license used for this package. The required copyright notice is included in the [`LICENSE`](LICENSE) file for this package.

0 commit comments

Comments
 (0)