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
chore(cli): Remove HTTP for now (#57)
Amaury Martinyaad2a0a02dea
diff --git a/Cargo.lock b/Cargo.lockindex 20fbe845..27c2106c 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -119,20 +119,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"[[package]]name = "check_if_email_exists"-version = "0.2.3"+version = "0.3.0"dependencies = [- "check_if_email_exists_core 0.2.3",+ "check_if_email_exists_core 0.3.0","clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)","env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",- "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",- "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)","serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)","serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",][[package]]name = "check_if_email_exists_core"-version = "0.2.3"+version = "0.3.0"dependencies = ["lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)","log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",@@ -146,9 +144,9 @@ dependencies = [[[package]]name = "check_if_email_exists_serverless"-version = "0.2.3"+version = "0.3.0"dependencies = [- "check_if_email_exists_core 0.2.3",+ "check_if_email_exists_core 0.3.0","lambda_http 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)","lambda_runtime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)","serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",diff --git a/README.md b/README.mdindex 674081d0..5a39a412 100644--- a/README.md+++ b/README.md@@ -20,7 +20,7 @@ Many online services (https://hunter.io, http://verify-email.org, http://email-cHead to the [releases page](https://github.com/amaurymartiny/check_if_email_exists/releases) and download the binary for your platform.-> Note: The binary doesn't connect to the above serverless backend, it runs from your computer.+> Note: The binary doesn't connect to the above serverless backend, it checks the mail directly from your computer.## Usage@@ -35,12 +35,39 @@ FLAGS:-V, --version Prints version informationOPTIONS:- --from <FROM_EMAIL> The from email to use in the SMTP connection (default: [email protected])+ --from <FROM_EMAIL> The from email to use in the SMTP connection [default: [email protected]]ARGS:<TO_EMAIL> The email to check```+The output will be a JSON with the following format, for `[email protected]`:++```json+{+ "mx": {+ "records": [+ "alt3.gmail-smtp-in.l.google.com.",+ "gmail-smtp-in.l.google.com.",+ "alt1.gmail-smtp-in.l.google.com.",+ "alt4.gmail-smtp-in.l.google.com.",+ "alt2.gmail-smtp-in.l.google.com."+ ]+ },+ "smtp": {+ "deliverable": false, // [email protected] is indeed disabled by Google+ "full_inbox": false,+ "has_catch_all": false+ },+ "syntax": {+ "address": "[email protected]",+ "domain": "gmail.com",+ "username": "someone",+ "valid_format": true+ }+}+```+### Verbose ModeTo show debug logs when running the binary, run:@@ -63,7 +90,7 @@ The 1st version of this tool was a simple bash script which made a telnet call.## Build From Source-First, [install Rust](https://www.rust-lang.org/tools/install). Then, clone the source code locally:+First, [install Rust](https://www.rust-lang.org/tools/install); you'll need Rust 1.37.0 or later. Then, clone the source code locally:```bash# Download the codediff --git a/cli/Cargo.toml b/cli/Cargo.tomlindex d9a1d09c..78d2062e 100644--- a/cli/Cargo.toml+++ b/cli/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check_if_email_exists"-version = "0.2.3"+version = "0.3.0"authors = ["Amaury Martiny <[email protected]>"]default-run = "check_if_email_exists"description = "Check if an email address exists without sending any email"@@ -11,7 +11,5 @@ publish = falsecheck_if_email_exists_core = { path = "../core" }clap = { version = "2.32", features = ["yaml"] }env_logger = "0.6"-futures = "0.1"-hyper = "0.12"serde = "1.0"serde_json = "1.0"diff --git a/cli/src/cli.yml b/cli/src/cli.ymlindex 014664a6..4b235654 100644--- a/cli/src/cli.yml+++ b/cli/src/cli.yml@@ -1,5 +1,5 @@name: check_if_email_exists-version: '0.2.3'+version: '0.3.0'author: Amaury Martiny <[email protected]>about: Check if an email address exists without sending any email.args:@@ -8,15 +8,7 @@ args:long: fromhelp: The from email to use in the SMTP connectiontakes_value: true- - HTTP:- long: http- help: Runs a HTTP server- - HTTP_PORT:- default_value: '3000'- long: http-port- help: Sets the port on which the HTTP server should bind. Only used when `--http` flag is on- takes_value: true- value_name: PORT- TO_EMAIL:help: The email to checkindex: 1+ required: truediff --git a/cli/src/http.rs b/cli/src/http.rsdeleted file mode 100644index ab8b3e50..00000000--- a/cli/src/http.rs+++ /dev/null@@ -1,93 +0,0 @@-// check_if_email_exists-// Copyright (C) 2018-2019 Amaury Martiny--// check_if_email_exists is free software: you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation, either version 3 of the License, or-// (at your option) any later version.--// check_if_email_exists is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.--// You should have received a copy of the GNU General Public License-// along with check_if_email_exists. If not, see <http://www.gnu.org/licenses/>.--use futures::future;-use futures::Stream;-use hyper::rt::Future;-use hyper::service::service_fn;-use hyper::{Body, Request, Response, Server};-use hyper::{Method, StatusCode};-use serde::{Deserialize, Serialize};--type BoxFut = Box<dyn Future<Item = Response<Body>, Error = hyper::Error> + Send>;--/// JSON Request from POST /-#[derive(Debug, Deserialize, Serialize)]-pub struct PostReqBody {- from_email: String,- to_email: String,-}--/// Error Response from POST /-#[derive(Debug, Deserialize, Serialize)]-pub struct PostResError {- error: String,-}-fn req_handler(req: Request<Body>) -> BoxFut {- let mut response = Response::new(Body::empty());-- match (req.method(), req.uri().path()) {- // Show instructions on GET /- (&Method::GET, "/") => {- *response.body_mut() =- Body::from("Send a POST request with JSON `{ \"from_email\": \"<email>\", to_email: \"<email>\" }` in the body");- }-- // Do email_exists check on POST /- (&Method::POST, "/") => {- let checked = req.into_body().concat2().map(move |chunk| {- let body = &chunk.iter().cloned().collect::<Vec<u8>>();- let result = match serde_json::from_slice::<PostReqBody>(body) {- Ok(b) => {- println!("YEAH! {:?}", b);- // serde_json::to_string(&email_exists(&b.from_email, &b.to_email)).unwrap()- serde_json::to_string("todo").unwrap()- }-- Err(err) => serde_json::to_string(&PostResError {- error: format!("{}", err),- })- .unwrap(),- };-- *response.body_mut() = Body::from(result);- response- });-- return Box::new(checked);- }-- // 404 page on all other routes- _ => {- *response.status_mut() = StatusCode::NOT_FOUND;- }- };-- Box::new(future::ok(response))-}--pub fn run(port: u16) -> () {- // This is our socket address...- let addr = ([127, 0, 0, 1], port).into();-- let server = Server::bind(&addr)- .serve(|| service_fn(req_handler))- .map_err(|e| eprintln!("server error: {}", e));-- // Run this server for... forever!- println!("Running server on localhost:{:?}", port);- hyper::rt::run(server);-}diff --git a/cli/src/main.rs b/cli/src/main.rsindex 7bcbd338..9d9082e8 100644--- a/cli/src/main.rs+++ b/cli/src/main.rs@@ -16,11 +16,8 @@extern crate clap;extern crate env_logger;-extern crate futures;extern crate serde;-mod http;-use check_if_email_exists_core::email_exists;use clap::App;use serde_json::Result as JsonResult;@@ -35,10 +32,6 @@ fn main() -> JsonResult<()> {let from_email = matches.value_of("FROM_EMAIL").expect("FROM_EMAIL has a default value. qed.");- let http_port = matches- .value_of("HTTP_PORT")- .expect("HTTP_PORT has a default value. qed.");- let is_http = matches.is_present("HTTP");let to_email = matches.value_of("TO_EMAIL").expect("TO_EMAIL is required. qed.");@@ -46,10 +39,5 @@ fn main() -> JsonResult<()> {let output = serde_json::to_string_pretty(&email_exists(&to_email, &from_email))?;println!("{}", output);- // Run the web server on :3000- if is_http {- http::run(http_port.parse::<u16>().unwrap());- }-Ok(())}diff --git a/core/Cargo.toml b/core/Cargo.tomlindex 9573c2fb..40260a3d 100644--- a/core/Cargo.toml+++ b/core/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check_if_email_exists_core"-version = "0.2.3"+version = "0.3.0"authors = ["Amaury Martiny <[email protected]>"]description = "Check if an email address exists without sending any email"edition = "2018"diff --git a/serverless/Cargo.toml b/serverless/Cargo.tomlindex 3b62c875..9d3133a7 100644--- a/serverless/Cargo.toml+++ b/serverless/Cargo.toml@@ -1,6 +1,6 @@[package]name = "check_if_email_exists_serverless"-version = "0.2.3"+version = "0.3.0"authors = ["Amaury Martiny <[email protected]>"]description = "Check if an email address exists without sending any email"edition = "2018"