Skip to content

Commit

Permalink
Only skip catch-all for hotmail
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Oct 6, 2023
1 parent af2d200 commit 4fa2c84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions core/src/smtp/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -224,7 +224,7 @@ async fn smtp_is_catch_all(
) -> Result<bool, SmtpError> {
// 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);
}

Expand Down
16 changes: 6 additions & 10 deletions core/src/smtp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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());
Expand Down
18 changes: 17 additions & 1 deletion core/src/smtp/outlook/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

0 comments on commit 4fa2c84

Please sign in to comment.