Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.
Rust emailemail-validationemail-validation-apiemail-verificationemail-verification-apiemail-verifierhacktoberfest
feat(backend): Customize SMTP defaults
Amaury8f152b83c70b
diff --git a/backend/README.md b/backend/README.mdindex 6621118c..81a67c96 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 followiThese 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 `<MAIL FROM:>` SMTP step. Can be overwritten by each API request's `from_email` field. | [email protected] |+| `RCH_HELLO_NAME` | No | Name to use in the `<EHLO>` 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 Documentationdiff --git a/backend/src/check.rs b/backend/src/check.rsindex a3b79072..b44bfe84 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};