Please enable JavaScript in your browser.

Overview

This Rust package provides an easy way to call the MailboxValidator Email Validation API which validates if an email address is a valid one.

NOTE: An API key will be given to you when you signup for any of our API plans. This module will require that API key to function.


Installation

Add the following code into your Cargo.toml
mailboxvalidator = "1.0.0"

Sample Codes

To validate an email address
use mailboxvalidator;

let validation_result = mailboxvalidator::validate_email("example@example.com",PASTE_API_KEY_HERE);

match validation_result {
    Ok(num) => {
        let ok_result = num;
        assert_eq!(ok_result["status"], "False");
        assert_eq!(ok_result["error_code"], "");
    },
    Err(err) => println!("{:#?}", err),
};

To check if an email is from a disposable email provider
use mailboxvalidator;

let validation_result = mailboxvalidator::is_disposable_email("example@example.com",PASTE_API_KEY_HERE);

match validation_result {
    Ok(num) => {
        let ok_result = num;
        assert_eq!(ok_result["is_disposable"], "True");
        assert_eq!(ok_result["error_code"], "");
    },
    Err(err) => println!("{:#?}", err),
};

To check if an email is from a free email provider
use mailboxvalidator;

let validation_result = mailboxvalidator::is_free_email("example@example.com",PASTE_API_KEY_HERE);

match validation_result {
    Ok(num) => {
        let ok_result = num;
        assert_eq!(ok_result["is_free"], "False");
        assert_eq!(ok_result["error_code"], "");
    },
    Err(err) => println!("{:#?}", err),
};

Related Videos