Skip to content

Commit

Permalink
feat(backend): Support RCH_SMTP_TIMEOUT (#1407)
Browse files Browse the repository at this point in the history
* feat(backend): Support RCH_SMTP_TIMEOUT

* fix clippy
  • Loading branch information
amaury1093 authored Dec 12, 2023
1 parent 22e8e3e commit b9bda40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ These are the environment variables used to configure the HTTP server. To pass t
| `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. | reacher.email@gmail.com |
| `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_SMTP_TIMEOUT` | No | Timeout for each SMTP connection. | 45s |
| `RCH_WEBDRIVER_ADDR` | No | Set to a running WebDriver process endpoint (e.g. `http://localhost:9515`) to use a headless navigator to password recovery pages to check Yahoo and Hotmail/Outlook addresses. We recommend `chromedriver` as it allows parallel requests. | not defined |

## REST API Documentation
Expand Down
8 changes: 7 additions & 1 deletion backend/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! This file contains shared logic for checking one email.
use std::env;
use std::{env, time::Duration};

use check_if_email_exists::{check_email as ciee_check_email, CheckEmailInput, CheckEmailOutput};
use warp::Filter;
Expand All @@ -30,12 +30,18 @@ pub async fn check_email(input: CheckEmailInput) -> CheckEmailOutput {
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 smtp_timeout = env::var("RCH_SMTP_TIMEOUT")
.ok()
.and_then(|s| s.parse::<u64>().ok())
.map(Duration::from_secs)
.or_else(|| CheckEmailInput::default().smtp_timeout);

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.
from_email,
hello_name,
smtp_timeout,
..input
};

Expand Down

0 comments on commit b9bda40

Please sign in to comment.