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(core): Improve invalid parser (#1166)
Amaurybb460046bf1c
diff --git a/backend/tests/check_email.rs b/backend/tests/check_email.rsindex 8679ec32..cf6278bc 100644--- a/backend/tests/check_email.rs+++ b/backend/tests/check_email.rs@@ -27,26 +27,28 @@ const FOO_BAR_BAZ_RESPONSE: &str = r#"{"input":"[email protected]","is_reachable":"inv#[tokio::test]async fn test_input_foo_bar() {- env::remove_var("RCH_HEADER_SECRET");+ env::set_var("RCH_HEADER_SECRET", "foobar");let resp = request().path("/v0/check_email").method("POST")+ .header(REACHER_SECRET_HEADER, "foobar").json(&serde_json::from_str::<EndpointRequest>(r#"{"to_email": "foo@bar"}"#).unwrap()).reply(&create_routes(None)).await;- assert_eq!(resp.status(), StatusCode::OK);+ assert_eq!(resp.status(), StatusCode::OK, "{:?}", resp.body());assert_eq!(resp.body(), FOO_BAR_RESPONSE);}#[tokio::test]async fn test_input_foo_bar_baz() {- env::remove_var("RCH_HEADER_SECRET");+ env::set_var("RCH_HEADER_SECRET", "foobar");let resp = request().path("/v0/check_email").method("POST")+ .header(REACHER_SECRET_HEADER, "foobar").json(&serde_json::from_str::<EndpointRequest>(r#"{"to_email": "[email protected]"}"#).unwrap()).reply(&create_routes(None)).await;@@ -66,7 +68,7 @@ async fn test_reacher_secret_missing_header() {.reply(&create_routes(None)).await;- assert_eq!(resp.status(), StatusCode::BAD_REQUEST);+ assert_eq!(resp.status(), StatusCode::BAD_REQUEST, "{:?}", resp.body());assert_eq!(resp.body(), r#"Missing request header "x-reacher-secret""#);}@@ -82,7 +84,7 @@ async fn test_reacher_secret_wrong_secret() {.reply(&create_routes(None)).await;- assert_eq!(resp.status(), StatusCode::BAD_REQUEST);+ assert_eq!(resp.status(), StatusCode::BAD_REQUEST, "{:?}", resp.body());assert_eq!(resp.body(), r#"Invalid request header "x-reacher-secret""#);}@@ -98,6 +100,6 @@ async fn test_reacher_secret_correct_secret() {.reply(&create_routes(None)).await;- assert_eq!(resp.status(), StatusCode::OK);+ assert_eq!(resp.status(), StatusCode::OK, "{:?}", resp.body());assert_eq!(resp.body(), FOO_BAR_RESPONSE);}diff --git a/core/src/smtp/parser.rs b/core/src/smtp/parser.rsindex 337cc4ab..e1f25a31 100644--- a/core/src/smtp/parser.rs+++ b/core/src/smtp/parser.rs@@ -85,6 +85,12 @@ pub fn is_invalid(e: &str, email: &EmailAddress) -> bool {|| e.contains("no longer available")// permanent: RCPT (<EMAIL>) dosn't exist (on @hgy.ooo)|| e.contains("dosn't exist") // sic! typo is intentional+ // 5.1.1 <EMAIL>: Email address could not be found, or was misspelled (G8) (on biotech-calendar.com, invoicefactoring.com)+ || e.contains("could not be found")+ // No such person at this address (on aconsa.com.mx)+ || e.contains("no such person")+ // Callout verification failed: 550 No Such User Here (on medipro.co.uk)+ || e.contains("callout verification failed")}/// Check that the mailbox has a full inbox.@@ -94,9 +100,9 @@ pub fn is_full_inbox(e: &str) -> bool {|| e.contains("mailbox full")// https://answers.microsoft.com/en-us/outlook_com/forum/all/how-do-i-interpret-the-delivery-failure-message/2f1bf9c0-8b03-4f8f-aacc-5f6ba60a73f3|| e.contains("quote exceeded")- || e.contains("over quota")- // 550 user has too many messages on the server- || e.contains("too many messages")+ || e.contains("over quota")+ // 550 user has too many messages on the server+ || e.contains("too many messages")}/// Check if the email account has been disabled or blocked by the email