Expand description
check-if-email-exists lets you check if an email address exists without
sending any email.
Under the hood, it connects to the email address’s SMTP server, and, analyzing the server’s responses against some SMTP commands, finds out information about the email address, such as:
- Email deliverability: Is an email sent to this address deliverable?
- Syntax validation. Is the address syntactically valid?
- DNS records validation. Does the domain of the email address have valid MX DNS records?
- Disposable email address (DEA) validation. Is the address provided by a known disposable email address provider?
- SMTP server validation. Can the mail exchanger of the email address domain be contacted successfully?
- Mailbox disabled. Has this email address been disabled by the email provider?
- Full inbox. Is the inbox of this mailbox full?
- Catch-all address. Is this email address a catch-all address?
use check_if_email_exists::{check_email, CheckEmailInputBuilder, CheckEmailInputProxy};
use check_if_email_exists::smtp::verif_method::{VerifMethod, VerifMethodSmtpConfig, GmailVerifMethod};
use std::collections::HashMap;
async fn check() {
// Let's say we want to test the deliverability of someone@gmail.com.
// We can tweak how we want to verify the email address, though using
// the default values is usually enough. However, if you want to use a
// proxy, you can do so like this:
let mut proxies = HashMap::new();
proxies.insert("proxy1".to_string(), CheckEmailInputProxy {
host: "my-proxy.io".to_string(), // Use a SOCKS5 proxy to verify the email
port: 1080,
username: None, // You can also set it non-empty
password: None,
timeout_ms: None,
});
let verif_method = VerifMethod {
proxies,
gmail: GmailVerifMethod::Smtp(VerifMethodSmtpConfig {
from_email: "me@example.org".to_string(), // Used in the `MAIL FROM:` command
hello_name: "example.org".to_string(), // Used in the `EHLO` command
smtp_port: 587, // Use port 587 instead of 25
proxy: Some("proxy1".to_string()), // Use the proxy we defined above
..Default::default()
}),
..Default::default()
};
let input = CheckEmailInputBuilder::default()
.to_email("someone@gmail.com".into())
.verif_method(verif_method)
.build()
.unwrap();
// Verify this input, using async/await syntax.
let result = check_email(&input).await;
// `result` is a `Vec<CheckEmailOutput>`, where the CheckEmailOutput
// struct contains all information about one email.
println!("{:?}", result);
}Re-exports§
pub use smtp::is_gmail;pub use smtp::is_hotmail;pub use smtp::is_hotmail_b2b;pub use smtp::is_hotmail_b2c;pub use smtp::is_yahoo;
Modules§
Structs§
- Check
Email Input - Builder pattern for the input argument into the main
email_existsfunction. - Check
Email Input Builder - Builder for
CheckEmailInput. - Check
Email Input Proxy - Perform the email verification via a specified proxy. The usage of a proxy is optional.
- Check
Email Output - The result of the check_email function.
- Debug
Details - Details about the email verification used for debugging.
- Email
Address - Wrapper around the
EmailAddressfromasync_smtpto allow for serialization and deserialization. - Webdriver
Config - Webdriver
Config Builder - Builder for
WebdriverConfig.
Enums§
- Check
Email Input Builder Error - Error type for CheckEmailInputBuilder
- Reachable
- An enum to describe how confident we are that the recipient address is real.
- Webdriver
Config Builder Error - Error type for WebdriverConfigBuilder
Constants§
- LOG_
TARGET - The target where to log check-if-email-exists logs.
Functions§
- check_
email - The main function of this library: verify a single email. Performs, in the following order, 4 types of verifications:
- initialize_
crypto_ provider - check-if-email-exists uses rustls for its TLS connections. This function initializes the default crypto provider for rustls.