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
fix: Add "recipient address accepted" check (#489)
Amaury Martiny5d1e72ae165f
diff --git a/README.md b/README.mdindex 0186d919..fb99eff7 100644--- a/README.md+++ b/README.md@@ -8,7 +8,7 @@<br /><br /><br /><h1 align="center">check-if-email-exists</h1>-<h4 align="center">Check if an email address exists before sending the email.</h4>+<h4 align="center">Check if an email address exists without sending any email.</h4><br /><br /><br />@@ -258,8 +258,8 @@ The 1st version of this tool was a simple bash script which made a telnet call.The source code is available under the license beard dude loves. See the [LICENSE](./LICENSE) file for more info.-## 🌯 Falafel Wrap--[](https://github.com/sponsors/amaurymartiny/)+## 🌯 Sponsor meI don't drink coffee, but I'd enjoy a wrap from my favorite Falafel dealer. 👉 [See which one.](https://github.com/sponsors/amaurymartiny/)++[](https://github.com/sponsors/amaurymartiny/)diff --git a/core/src/lib.rs b/core/src/lib.rsindex 84ac26fb..f077b50d 100644--- a/core/src/lib.rs+++ b/core/src/lib.rs@@ -154,38 +154,29 @@ async fn check_single_email(input: CheckEmailInput) -> CheckEmailOutput {my_misc);- // Create one future per lookup result.- let futures = my_mx+ // We simply take the first lookup result, and connect to that SMTP server.+ // FIXME Add retry mechanism to other lookup results.+ let my_smtp = my_mx.lookup.as_ref()- .map(|lookup| {- lookup- .iter()- .map(|host| {- let fut = check_smtp(- my_syntax- .address- .as_ref()- .expect("We already checked that the email has valid format. qed."),- host.exchange(),- // FIXME We could add ports 465 and 587 too.- SMTP_PORT,- my_syntax.domain.as_ref(),- &input,- );-- // https://rust-lang.github.io/async-book/04_pinning/01_chapter.html- Box::pin(fut)- })- .collect::<Vec<_>>()+ .expect("If lookup is error, we already returned. qed.")+ .iter()+ .next()+ .map(|host| {+ check_smtp(+ my_syntax+ .address+ .as_ref()+ .expect("We already checked that the email has valid format. qed."),+ host.exchange(),+ // FIXME We could add ports 465 and 587 too.+ SMTP_PORT,+ my_syntax.domain.as_ref(),+ &input,+ )})- .expect("If lookup is empty, we already returned. qed.");-- // Race, return the first future that resolves.- let my_smtp = match future::select_ok(futures).await {- Ok((details, _)) => Ok(details),- Err(err) => Err(err),- };+ .expect("Lookup cannot be empty. qed.")+ .await;CheckEmailOutput {input: to_email.to_string(),diff --git a/core/src/smtp/mod.rs b/core/src/smtp/mod.rsindex 5bd2950f..7a0ef4bd 100644--- a/core/src/smtp/mod.rs+++ b/core/src/smtp/mod.rs@@ -190,7 +190,10 @@ async fn email_deliverable({Ok(response) => match response.first_line() {Some(message) => {- let is_deliverable = message.contains("2.1.5");+ let message = message.to_lowercase();+ let is_deliverable = message.contains("2.1.5") ||+ // 250 Recipient address accepted+ message.contains("recipient address accepted");Ok(Deliverability {has_full_inbox: false,is_deliverable,