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
Add from in config
Amaury Martiny75d28d6a3c30
diff --git a/src/cli.yml b/src/cli.ymlindex 4add0633..ceda820b 100644--- a/src/cli.yml+++ b/src/cli.yml@@ -3,7 +3,12 @@ version: '0.1.0'author: Amaury Martiny <[email protected]>about: Check if an email address exists without sending any email.args:- - EMAIL:+ - from:+ long: from+ help: 'The from email to use in the Telnet connection (default: [email protected])'+ takes_value: true+ value_name: FROM+ - TO:help: The email to checkrequired: trueindex: 1diff --git a/src/main.rs b/src/main.rsindex 6acc1ab8..fe84113b 100644--- a/src/main.rs+++ b/src/main.rs@@ -18,14 +18,15 @@ fn main() {let matches = App::from_yaml(yaml).get_matches();// Calling .unwrap() is safe here because "EMAIL" is required- let email = matches.value_of("EMAIL").unwrap();+ let from_email = matches.value_of("from").unwrap_or("[email protected]");+ let to_email = matches.value_of("TO").unwrap();- debug!("Testing email {}...", email);+ debug!("Testing email {}...", to_email);- let domain = match email.split("@").skip(1).next() {+ let domain = match to_email.split("@").skip(1).next() {Some(i) => i,None => {- error!("{} is not a valid email.", email);+ error!("{} is not a valid email.", to_email);::std::process::exit(1);}};@@ -36,12 +37,7 @@ fn main() {let ports = vec![25, 465, 587];for port in ports.into_iter() {for host in hosts.iter() {- if telnet::connect(- "[email protected]",- email,- host.exchange(),- port,- ) {+ if telnet::connect(from_email, to_email, host.exchange(), port) {println!("true");process::exit(0x0100);};diff --git a/src/telnet.rs b/src/telnet.rsindex 1739e062..05f1558a 100644--- a/src/telnet.rs+++ b/src/telnet.rs@@ -49,11 +49,11 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {debug!("Received: {}", answer);// `question` is what we ask the server- let question = match step {+ let mut question = match step {Step::Welcome => {if answer.contains("220") {step = Step::SentHelo;- String::from("HELO Hi\n")+ String::from("HELO Hi")} else {break;}@@ -61,7 +61,7 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {Step::SentHelo => {if answer.contains("250") {step = Step::SentMailFrom;- format!("{}{}{}", "MAIL FROM: <", from, ">\n")+ format!("{}{}{}", "MAIL FROM: <", from, ">")} else {break;}@@ -69,7 +69,7 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {Step::SentMailFrom => {if answer.contains("2.1.0") {step = Step::SentRcptTo;- format!("{}{}{}", "RCPT TO: <", to, ">\n")+ format!("{}{}{}", "RCPT TO: <", to, ">")} else {break;}@@ -81,7 +81,7 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {} else {step = Step::NotFound;}- String::from("QUIT\n")+ String::from("QUIT")}_ => panic!("Step is Found/NotFound where it shouldn't be."),};@@ -89,7 +89,8 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {debug!("Sent: {}", question);// Buffer to write to telnet- let write_buffer = question.as_bytes(); // TODO Define buffer depending on read_buffer+ question.push_str("\n");+ let write_buffer = question.as_bytes();if let Err(e) = connection.write(&write_buffer) {debug!("Error while writing, {}", e);}