diff --git a/core/src/smtp/connect.rs b/core/src/smtp/connect.rs index 3d9fc129f..97a579dcd 100644 --- a/core/src/smtp/connect.rs +++ b/core/src/smtp/connect.rs @@ -29,7 +29,7 @@ use std::time::Duration; use trust_dns_proto::rr::Name; -use super::{gmail::is_gmail, outlook::is_outlook, parser, yahoo::is_yahoo}; +use super::{gmail::is_gmail, outlook::is_hotmail, parser, yahoo::is_yahoo}; use super::{SmtpDetails, SmtpError}; use crate::util::{constants::LOG_TARGET, input_output::CheckEmailInput}; @@ -224,7 +224,7 @@ async fn smtp_is_catch_all( ) -> Result { // Skip catch-all check for known providers. let host = host.to_string(); - if is_gmail(&host) || is_outlook(&host) || is_yahoo(&host) { + if is_gmail(&host) || is_hotmail(&host) || is_yahoo(&host) { return Ok(false); } diff --git a/core/src/smtp/mod.rs b/core/src/smtp/mod.rs index 69d0564f1..0b56d4c4e 100644 --- a/core/src/smtp/mod.rs +++ b/core/src/smtp/mod.rs @@ -32,7 +32,11 @@ use crate::{util::input_output::CheckEmailInput, LOG_TARGET}; use connect::check_smtp_with_retry; pub use error::*; -use self::{gmail::is_gmail, outlook::is_outlook, yahoo::is_yahoo}; +use self::{ + gmail::is_gmail, + outlook::{is_hotmail, is_outlook}, + yahoo::is_yahoo, +}; /// Details that we gathered from connecting to this email via SMTP #[derive(Debug, Default, Deserialize, Serialize)] @@ -100,15 +104,7 @@ pub async fn check_smtp( // The password recovery page do not always work with Microsoft 365 // addresses. So we only test with @hotmail and @outlook addresses. // ref: https://github.com/reacherhq/check-if-email-exists/issues/1185 - // - // After some testing, I got: - // - *@outlook.com -> `outlook-com.olc.protection.outlook.com.` - // - *@outlook.fr -> `eur.olc.protection.outlook.com.` - // - *@hotmail.com -> `hotmail-com.olc.protection.outlook.com.` - // - *@hotmail.fr -> `eur.olc.protection.outlook.com.` - // - // So it seems that outlook/hotmail addresses end with `olc.protection.outlook.com.` - if host_lowercase.ends_with("olc.protection.outlook.com.") { + if is_hotmail(&host_lowercase) { return outlook::hotmail::check_password_recovery(to_email, webdriver) .await .map_err(|err| err.into()); diff --git a/core/src/smtp/outlook/mod.rs b/core/src/smtp/outlook/mod.rs index 92a80a77f..3c8c9c077 100644 --- a/core/src/smtp/outlook/mod.rs +++ b/core/src/smtp/outlook/mod.rs @@ -2,8 +2,24 @@ pub mod hotmail; pub mod microsoft365; -/// Check if a MX host is from outlook. +/// Check if a MX host is from outlook (includes @hotmail.*, @outlook.* and +/// all Microsoft 365 addresses). pub fn is_outlook(host: &str) -> bool { host.to_lowercase() .ends_with(".mail.protection.outlook.com.") } + +/// Check if a MX host is an @hotmail.* or @outlook.* email. +/// +/// After some testing, I got: +/// - *@outlook.com -> `outlook-com.olc.protection.outlook.com.` +/// - *@outlook.fr -> `eur.olc.protection.outlook.com.` +/// - *@hotmail.com -> `hotmail-com.olc.protection.outlook.com.` +/// - *@hotmail.fr -> `eur.olc.protection.outlook.com.` +/// - *@hotmail.nl -> `eur.olc.protection.outlook.com.` +/// +/// So it seems that outlook/hotmail addresses end with `olc.protection.outlook.com.` +pub fn is_hotmail(host: &str) -> bool { + host.to_lowercase() + .ends_with(".mail.protection.outlook.com.") +}