Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

Add combinations of host:port

Amaury Martiny559af74d2f6c
diff --git a/src/main.rs b/src/main.rs
index bae88289..0720c55b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -21,7 +21,7 @@ fn main() {
// Calling .unwrap() is safe here because "EMAIL" is required
let to_email = matches.value_of("TO").unwrap();
- debug!("Testing email {}...", to_email);
+ debug!("User inputted email {}", to_email);
let domain = match to_email.split("@").skip(1).next() {
Some(i) => i,
@@ -30,18 +30,23 @@ fn main() {
process::exit(1);
}
};
+ debug!("Domain name is: {}", domain);
- debug!("Domain is: {}", domain);
-
+ debug!("Getting MX lookup...");
let hosts = mx_hosts::get_mx_lookup(domain);
+ debug!("Found the following MX hosts {:?}", hosts);
let ports = vec![25, 465, 587];
+ let mut combinations = Vec::new(); // `(host, port)` combination
for port in ports.into_iter() {
for host in hosts.iter() {
- if telnet::connect(from_email, to_email, host.exchange(), port) {
- println!("true");
- process::exit(0x0100);
- };
+ combinations.push((host.exchange(), port))
}
}
+ for c in combinations {
+ let (domain, port) = c;
+ let found = telnet::connect(from_email, to_email, domain, port);
+ debug!("found? {}", found)
+ }
+
println!("false");
}
diff --git a/src/telnet.rs b/src/telnet.rs
index f299268a..8aeb1485 100644
--- a/src/telnet.rs
+++ b/src/telnet.rs
@@ -16,7 +16,7 @@ enum Step {
}
pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {
- debug!("Telnet connection to {}...", domain);
+ debug!("Telnet connection to {}:{}...", domain, port);
let mut connection = match Telnet::connect((domain.to_utf8().as_str(), port), 256) {
Ok(i) => i,
@@ -35,7 +35,7 @@ pub fn connect(from: &str, to: &str, domain: &Name, port: u16) -> bool {
// telnet connection.
let event = match connection.read() {
Ok(i) => i,
- Err(_) => break,
+ _ => break,
};
if let TelnetEvent::Data(read_buffer) = event {