Skip to main content

Crate check_if_email_exists

Crate check_if_email_exists 

Source
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§

misc
mx
smtp
syntax

Structs§

CheckEmailInput
Builder pattern for the input argument into the main email_exists function.
CheckEmailInputBuilder
Builder for CheckEmailInput.
CheckEmailInputProxy
Perform the email verification via a specified proxy. The usage of a proxy is optional.
CheckEmailOutput
The result of the check_email function.
DebugDetails
Details about the email verification used for debugging.
EmailAddress
Wrapper around the EmailAddress from async_smtp to allow for serialization and deserialization.
WebdriverConfig
WebdriverConfigBuilder
Builder for WebdriverConfig.

Enums§

CheckEmailInputBuilderError
Error type for CheckEmailInputBuilder
Reachable
An enum to describe how confident we are that the recipient address is real.
WebdriverConfigBuilderError
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.