Skip to content

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

Remove server info

Amaury Martinyfc7a31e98d80
diff --git a/src/lib.rs b/src/lib.rs
index 926d40af..4c2973b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -27,7 +27,7 @@ pub fn email_exists(from_email: &str, to_email: &str) -> bool {
debug!("Getting MX lookup...");
let hosts = mx_hosts::get_mx_lookup(domain);
- info!("Found the following MX hosts {:?}", hosts);
+ debug!("Found the following MX hosts {:?}", hosts);
let ports = vec![SMTP_PORT, SUBMISSION_PORT, SUBMISSIONS_PORT];
let mut combinations = Vec::new(); // `(host, port)` combination
for port in ports.into_iter() {
@@ -37,7 +37,7 @@ pub fn email_exists(from_email: &str, to_email: &str) -> bool {
}
match combinations
- .par_iter() // Parallelize the find_any
+ .par_iter() // Parallelize the filter_map
.filter_map(|(host, port)| smtp::email_exists(from_email, to_email, host, *port))
.find_any(|_| true)
{
diff --git a/src/smtp.rs b/src/smtp.rs
index 031d5ec2..3c308751 100644
--- a/src/smtp.rs
+++ b/src/smtp.rs
@@ -1,7 +1,7 @@
use lettre::smtp::client::net::NetworkStream;
use lettre::smtp::client::InnerClient;
use lettre::smtp::commands::*;
-use lettre::smtp::extension::{ClientId, ServerInfo};
+use lettre::smtp::extension::ClientId;
use lettre::EmailAddress;
use std::time::Duration;
use trust_dns_resolver::Name;
@@ -40,15 +40,13 @@ pub fn email_exists(from: &str, to: &str, host: &Name, port: u16) -> Option<bool
port
);
- // Send ehlo and get server info.
- let ehlo_response = try_smtp!(
+ // Send ehlo.
+ try_smtp!(
smtp_client.command(EhloCommand::new(ClientId::new("localhost".to_string()))),
smtp_client,
host,
port
);
- let server_info = ServerInfo::from_response(&ehlo_response);
- debug!("Server info: {}", server_info.as_ref().unwrap());
// Send from.
try_smtp!(