diff --git a/.env.example b/.env.example index 930dbab..2121e02 100644 --- a/.env.example +++ b/.env.example @@ -8,3 +8,9 @@ SMTP_PORT=587 SMTP_USER=resend SMTP_PASSWORD= MAIL_FROM=send@read.atanasov.fi + +# Comma-separated list of allowed destination email domains. Anything that +# doesn't match (suffix-wise, so subdomains like free.kindle.com count) is +# rejected with a 400. This prevents the app from being abused as an open +# email relay to arbitrary addresses. +ALLOWED_READER_DOMAINS=kindle.com,pbsync.com diff --git a/README.md b/README.md index c3261ce..5e59217 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,16 @@ Two ways to send something to your e-reader: ## Supported devices -Any device that accepts files via email works — the app doesn't restrict by domain. +The destination email domain is checked against an allowlist (default: `kindle.com`, `pbsync.com`) to prevent the app being used as an open email relay. Subdomains count, so `free.kindle.com` works too. | Device | Email pattern | |---|---| -| Amazon Kindle | `*@kindle.com` | +| Amazon Kindle | `*@kindle.com` (or `*.kindle.com` subdomains) | | PocketBook | `*@pbsync.com` | -| Anything else | whatever address your device gives you | -You'll need to add the **sender** address (the Gmail account this app sends from) to your device's approved-senders list — that's a one-time per-device setup. +You can extend the list via the `ALLOWED_READER_DOMAINS` env var (see below). + +You'll also need to add the **sender** address to your device's approved-senders list — one-time per device. ## Prerequisites @@ -63,6 +64,7 @@ npm run start | `SMTP_USER` | yes | — | For Resend, literally the string `resend` | | `SMTP_PASSWORD` | yes | — | For Resend, your API key (`re_…`) | | `MAIL_FROM` | yes | — | Sender address, e.g. `read@atanasov.fi`. Must be from a verified domain on your provider. | +| `ALLOWED_READER_DOMAINS` | no | `kindle.com,pbsync.com` | Comma-separated allowlist of destination email domains. Suffix-matching, so subdomains are allowed. | | `PORT` | no | `3000` | Listen port | ## Resend setup (quick) diff --git a/public/index.html b/public/index.html index 758c190..17f3a86 100644 --- a/public/index.html +++ b/public/index.html @@ -260,7 +260,12 @@
@kindle.com and @pbsync.com
+ destination addresses are accepted (subdomains too, e.g.
+ free.kindle.com). This is to prevent the form being
+ abused as an open email relay.
+