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
Rename variables
Amaury Martinyc13d96a69e74
diff --git a/Cargo.toml b/Cargo.tomlindex 75cf4f91..a0445a50 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -8,8 +8,9 @@ name = "check_if_email_exists"path = "src/lib.rs"[[bin]]-name = "check_if_email_exists_bin"+name = "check_if_email_exists"path = "src/bin/main.rs"+doc = false[dependencies]clap = {version = "2.32", features = ["yaml"]}diff --git a/src/bin/cli.yml b/src/bin/cli.ymlindex ceda820b..bcb5bb06 100644--- a/src/bin/cli.yml+++ b/src/bin/cli.yml@@ -3,12 +3,11 @@ version: '0.1.0'author: Amaury Martiny <[email protected]>about: Check if an email address exists without sending any email.args:- - from:+ - FROM_EMAIL:long: fromhelp: 'The from email to use in the Telnet connection (default: [email protected])'takes_value: true- value_name: FROM- - TO:+ - TO_EMAIL:help: The email to checkrequired: trueindex: 1diff --git a/src/bin/main.rs b/src/bin/main.rsindex 17815d65..809f61d5 100644--- a/src/bin/main.rs+++ b/src/bin/main.rs@@ -17,9 +17,9 @@ fn main() {let yaml = load_yaml!("cli.yml");let matches = App::from_yaml(yaml).get_matches();- let from_email = matches.value_of("from").unwrap_or("[email protected]");+ let from_email = matches.value_of("FROM_EMAIL").unwrap_or("[email protected]");// Calling .unwrap() is safe here because "TO" is required- let to_email = matches.value_of("TO").unwrap();+ let to_email = matches.value_of("TO_EMAIL").unwrap();println!("{}", email_exists(from_email, to_email));}diff --git a/src/smtp.rs b/src/smtp.rsindex 3c308751..32d79512 100644--- a/src/smtp.rs+++ b/src/smtp.rs@@ -20,7 +20,7 @@ macro_rules! try_smtp (}));-pub fn email_exists(from: &str, to: &str, host: &Name, port: u16) -> Option<bool> {+pub fn email_exists(from_email: &str, to_email: &str, host: &Name, port: u16) -> Option<bool> {debug!("Connecting to {}:{}...", host, port);let mut smtp_client: InnerClient<NetworkStream> = InnerClient::new();@@ -51,7 +51,7 @@ pub fn email_exists(from: &str, to: &str, host: &Name, port: u16) -> Option<bool// Send from.try_smtp!(smtp_client.command(MailCommand::new(- Some(EmailAddress::new(from.to_string()).unwrap()),+ Some(EmailAddress::new(from_email.to_string()).unwrap()),vec![],)),smtp_client,@@ -61,7 +61,7 @@ pub fn email_exists(from: &str, to: &str, host: &Name, port: u16) -> Option<bool// Send to.let result = match smtp_client.command(RcptCommand::new(- EmailAddress::new(to.to_string()).unwrap(),+ EmailAddress::new(to_email.to_string()).unwrap(),vec![],)) {Ok(response) => match response.first_line() {