From 8f152b83c70b94618b71308552a6999f4b27aa2f Mon Sep 17 00:00:00 2001 From: Amaury <1293565+amaury1729@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:08:31 +0200 Subject: [PATCH] feat(backend): Customize SMTP defaults --- backend/README.md | 28 +++++++++++++++------------- backend/src/check.rs | 22 ++++++---------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/backend/README.md b/backend/README.md index 6621118c1..81a67c967 100644 --- a/backend/README.md +++ b/backend/README.md @@ -48,19 +48,21 @@ Then send a `POST http://localhost:8080/v0/check_email` request with the followi These are the environment variables used to configure the HTTP server. To pass them to the Docker container, use the `-e {ENV_VAR}={VALUE}` flag. -| Env Var | Required? | Description | Default | -| ----------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| `RCH_ENABLE_BULK` | No | If set to `1`, then bulk verification endpoints will be added to the backend. | 0 | -| `DATABASE_URL` | Yes if `RCH_ENABLE_BULK==1` | Database connection string for storing results and task queue | not defined | -| `RCH_HTTP_HOST` | No | The host name to bind the HTTP server to. | `127.0.0.1` | -| `PORT` | No | The port to bind the HTTP server to, often populated by the cloud provider. | `8080` | -| `RCH_HOTMAIL_USE_HEADLESS` | No | Set to a running WebDriver process endpoint (e.g. `http://localhost:4444`) to use a headless navigator to Hotmail's password recovery page to check Hotmail/Outlook addresses. We recommend `chromedriver` as it allows parallel requests. | not defined | -| `RCH_SENTRY_DSN` | No | If set, bug reports will be sent to this [Sentry](https://sentry.io) DSN. | not defined | -| `RCH_HEADER_SECRET` | No | If set, then all HTTP requests must have the `x-reacher-secret` header set to this value. This is used to protect the backend against public unwanted HTTP requests. | undefined | -| `RCH_DATABASE_MAX_CONNECTIONS` | No | (Bulk) Connections created for the database pool | 5 | -| `RCH_MINIMUM_TASK_CONCURRENCY` | No | (Bulk) Minimum number of concurrent running tasks below which more tasks are fetched | 10 | -| `RCH_MAXIMUM_CONCURRENT_TASK_FETCH` | No | (Bulk) Maximum number of tasks fetched at once | 20 | -| `RUST_LOG` | No | One of `trace,debug,warn,error,info`. 💡 PRO TIP: `RUST_LOG=debug` is very handful for debugging purposes. | not defined | +| Env Var | Required? | Description | Default | +| ----------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- | +| `RUST_LOG` | No | One of `trace,debug,warn,error,info`. 💡 PRO TIP: `RUST_LOG=debug` is very handful for debugging purposes. | not defined | +| `RCH_ENABLE_BULK` | No | If set to `1`, then bulk verification endpoints will be added to the backend. | 0 | +| `DATABASE_URL` | Yes if `RCH_ENABLE_BULK==1` | [Bulk] Database connection string for storing results and task queue | not defined | +| `RCH_DATABASE_MAX_CONNECTIONS` | No | [Bulk] Connections created for the database pool | 5 | +| `RCH_MINIMUM_TASK_CONCURRENCY` | No | [Bulk] Minimum number of concurrent running tasks below which more tasks are fetched | 10 | +| `RCH_MAXIMUM_CONCURRENT_TASK_FETCH` | No | [Bulk] Maximum number of tasks fetched at once | 20 | +| `RCH_HTTP_HOST` | No | The host name to bind the HTTP server to. | `127.0.0.1` | +| `PORT` | No | The port to bind the HTTP server to, often populated by the cloud provider. | `8080` | +| `RCH_SENTRY_DSN` | No | If set, bug reports will be sent to this [Sentry](https://sentry.io) DSN. | not defined | +| `RCH_HEADER_SECRET` | No | If set, then all HTTP requests must have the `x-reacher-secret` header set to this value. This is used to protect the backend against public unwanted HTTP requests. | undefined | +| `RCH_FROM_EMAIL` | No | Email to use in the `` SMTP step. Can be overwritten by each API request's `from_email` field. | reacher.email@gmail.com | +| `RCH_HELLO_NAME` | No | Name to use in the `` SMTP step. Can be overwritten by each API request's `hello_name` field. | gmail.com | +| `RCH_HOTMAIL_USE_HEADLESS` | No | Set to a running WebDriver process endpoint (e.g. `http://localhost:4444`) to use a headless navigator to Hotmail's password recovery page to check Hotmail/Outlook addresses. We recommend `chromedriver` as it allows parallel requests. | not defined | ## REST API Documentation diff --git a/backend/src/check.rs b/backend/src/check.rs index a3b79072d..b44bfe84b 100644 --- a/backend/src/check.rs +++ b/backend/src/check.rs @@ -27,27 +27,17 @@ use super::sentry_util; /// inputs and error handling. pub async fn check_email(input: CheckEmailInput) -> CheckEmailOutput { let hotmail_use_headless = env::var("RCH_HOTMAIL_USE_HEADLESS").ok(); - let skipped_domains = vec![ - // on @bluewin.ch - // - mx-v02.bluewin.ch. - ".bluewin.ch.".into(), - // on @bluewin.ch - // - mxbw-bluewin-ch.hdb-cs04.ellb.ch. - "bluewin-ch.".into(), - // on @gmx.de, @gmx.ch, @gmx.net - ".gmx.net.".into(), - // on @icloud.com - ".mail.icloud.com.".into(), - // on @web.de - ".web.de.".into(), - ".zoho.com.".into(), - ]; + let from_email = + env::var("RCH_FROM_EMAIL").unwrap_or_else(|_| CheckEmailInput::default().from_email); + let hello_name = + env::var("RCH_HELLO_NAME").unwrap_or_else(|_| CheckEmailInput::default().hello_name); let input = CheckEmailInput { // If we want to override core check-if-email-exists's default values // for CheckEmailInput for the backend, we do it here. hotmail_use_headless, - skipped_domains, + from_email, + hello_name, ..input };