Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

fix(core): Fix hotmail headless with authenticator

Amaury M51cdb2e3c13a
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 859c675f..6604d91b 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -13,7 +13,7 @@ name = "check_if_email_exists"
path = "src/main.rs"
[dependencies]
-check-if-email-exists = { path = "../core" }
+check-if-email-exists = { path = "../core", features = ["headless"] }
clap = { version = "3.2", features = ["derive", "env"] }
env_logger = "0.9"
once_cell = "1.16"
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 6f5ff550..b4890d5d 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -63,6 +63,11 @@ pub struct Cli {
#[clap(long, env, default_value = "false", parse(try_from_str))]
pub gmail_use_api: bool,
+ /// For Hotmail addresses, use a headless browser to connect to the
+ /// Microsoft account recovery page.
+ #[clap(long, env)]
+ pub hotmail_use_headless: Option<String>,
+
/// For Microsoft 365 email addresses, use OneDrive's API instead of
/// connecting directly to their SMTP servers.
#[clap(long, env, default_value = "false", parse(try_from_str))]
@@ -93,7 +98,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
.set_yahoo_use_api(CONF.yahoo_use_api)
.set_gmail_use_api(CONF.gmail_use_api)
.set_microsoft365_use_api(CONF.microsoft365_use_api)
- .set_check_gravatar(CONF.check_gravatar);
+ .set_check_gravatar(CONF.check_gravatar)
+ .set_hotmail_use_headless(CONF.hotmail_use_headless.clone());
+
if let Some(proxy_host) = &CONF.proxy_host {
input.set_proxy(CheckEmailInputProxy {
host: proxy_host.clone(),
diff --git a/core/src/smtp/microsoft/hotmail.rs b/core/src/smtp/microsoft/hotmail.rs
index 00a424a5..7fae0431 100644
--- a/core/src/smtp/microsoft/hotmail.rs
+++ b/core/src/smtp/microsoft/hotmail.rs
@@ -63,7 +63,7 @@ pub async fn check_password_recovery(
to_email,
);
- // Running in a container, I run into the following error:
+ // Running in a Docker container, I run into the following error:
// Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
// In searching around I found a few different workarounds:
// - Enable namespaces: https://github.com/jessfraz/dockerfiles/issues/65#issuecomment-266532289
@@ -111,7 +111,13 @@ pub async fn check_password_recovery(
.wait()
.for_element(Locator::Id("iSelectProofTitle"))
.and_then(|_| async { Ok(true) });
- let is_deliverable = f1.try_race(f2).await?;
+ // "Enter the code generated by your authenticator app..."
+ let f3 = c
+ .wait()
+ .for_element(Locator::Id("iEnterVerification"))
+ .and_then(|_| async { Ok(true) });
+
+ let is_deliverable = f1.try_race(f2).try_race(f3).await?;
if is_deliverable {
log::debug!(