email-safeguard


Nameemail-safeguard JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/chukaibejih/email-validator
SummaryA Python library for validating and suggesting corrections for email addresses.
upload_time2024-08-07 14:41:11
maintainerNone
docs_urlNone
authorChukwuka Ibejih
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Email Safeguard

A robust email validation library with domain and TLD suggestions, disposable email detection, and MX record validation.

## Features

- Validates email format using Django's built-in validators.

- Detects disposable email addresses.

- Suggests corrections for common domain and TLD typos.

- Checks for valid MX records for the domain.

## Installation

To install the library, use pip:

```sh

pip install email-safeguard

```

## Usage

### Basic Usage

Here's an example of how to use the `EmailValidator` class:

```python

from email_validator.validator import EmailValidator

validator = EmailValidator()

result = validator.validate("user@example.com")

if result["valid"]:

    print("Email is valid!")

else:

    print("Error:", result["error"])

```

### Custom Domain and TLD Lists

You can customize the lists of popular domains, TLDs, and disposable domains by providing your own text files:

```python

validator = EmailValidator(

    domains_file='path/to/custom_domains.txt',

    tlds_file='path/to/custom_tlds.txt',

    disposable_file='path/to/custom_disposable_domains.txt'

)

```

## Data Files

The library uses three data files for validation:

- **popular_domains.txt**: A list of popular email domains.

- **popular_tlds.txt**: A list of popular top-level domains (TLDs).

- **disposable_domains.txt**: A list of known disposable email domains.

Each file should contain one entry per line.

### Example `popular_domains.txt`

```

gmail.com

yahoo.com

outlook.com

hotmail.com

```

### Example `popular_tlds.txt`

```

com

net

org

edu

```

### Example `disposable_domains.txt`

```

mailinator.com

10minutemail.com

```

## Full Example

Here's a more detailed example demonstrating all features:

```python

import os

from email_validator import EmailValidator

# Initialize the validator with custom data files

validator = EmailValidator(

    domains_file='data/popular_domains.txt',

    tlds_file='data/popular_tlds.txt',

    disposable_file='data/disposable_domains.txt'

)

emails = [

    "valid.email@gmail.com",

    "invalid-email",

    "test@mailinator.com",

    "user@gnail.com",

    "user@gmail.cmo",

    "user@nonexistentdomain.xyz"

]

for email in emails:

    result = validator.validate(email)

    if result["valid"]:

        print(f"{email} is valid!")

    else:

        print(f"Error with {email}: {result['error']}")

```

## Running Tests

To run the tests, use the following command:

```sh

python -m unittest discover

```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Feel free to contribute to this project if you want to add new features, improve existing ones, or fix bugs.

## Issues

Please raise and issue for bug reporst, feature requests or suggestions.
## Author

Chukwuka Ibejih

For any questions or feedback, please contact [chukaibejih@gmail.com](mailto:chukaibejih@gmail.com).

## Acknowledgements

This library uses the following third-party packages:

- [Django](https://www.djangoproject.com/) for email validation

- [Levenshtein](https://pypi.org/project/python-Levenshtein/) for string similarity calculations

- [dnspython](https://www.dnspython.org/) for DNS queries


If you love this project, please consider giving me a ⭐

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/chukaibejih/email-validator",
    "name": "email-safeguard",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chukwuka Ibejih",
    "author_email": "chukaibejih@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c7/6c/53f963e67cfbb5c4c9fcd352a72d0c65ade5aeb23e0a4e7395da257183df/email_safeguard-0.1.2.tar.gz",
    "platform": null,
    "description": "# Email Safeguard\r\n\r\nA robust email validation library with domain and TLD suggestions, disposable email detection, and MX record validation.\r\n\r\n## Features\r\n\r\n- Validates email format using Django's built-in validators.\r\n\r\n- Detects disposable email addresses.\r\n\r\n- Suggests corrections for common domain and TLD typos.\r\n\r\n- Checks for valid MX records for the domain.\r\n\r\n## Installation\r\n\r\nTo install the library, use pip:\r\n\r\n```sh\r\n\r\npip install email-safeguard\r\n\r\n```\r\n\r\n## Usage\r\n\r\n### Basic Usage\r\n\r\nHere's an example of how to use the `EmailValidator` class:\r\n\r\n```python\r\n\r\nfrom email_validator.validator import EmailValidator\r\n\r\nvalidator = EmailValidator()\r\n\r\nresult = validator.validate(\"user@example.com\")\r\n\r\nif result[\"valid\"]:\r\n\r\n\u00a0 \u00a0 print(\"Email is valid!\")\r\n\r\nelse:\r\n\r\n\u00a0 \u00a0 print(\"Error:\", result[\"error\"])\r\n\r\n```\r\n\r\n### Custom Domain and TLD Lists\r\n\r\nYou can customize the lists of popular domains, TLDs, and disposable domains by providing your own text files:\r\n\r\n```python\r\n\r\nvalidator = EmailValidator(\r\n\r\n\u00a0 \u00a0 domains_file='path/to/custom_domains.txt',\r\n\r\n\u00a0 \u00a0 tlds_file='path/to/custom_tlds.txt',\r\n\r\n\u00a0 \u00a0 disposable_file='path/to/custom_disposable_domains.txt'\r\n\r\n)\r\n\r\n```\r\n\r\n## Data Files\r\n\r\nThe library uses three data files for validation:\r\n\r\n- **popular_domains.txt**: A list of popular email domains.\r\n\r\n- **popular_tlds.txt**: A list of popular top-level domains (TLDs).\r\n\r\n- **disposable_domains.txt**: A list of known disposable email domains.\r\n\r\nEach file should contain one entry per line.\r\n\r\n### Example `popular_domains.txt`\r\n\r\n```\r\n\r\ngmail.com\r\n\r\nyahoo.com\r\n\r\noutlook.com\r\n\r\nhotmail.com\r\n\r\n```\r\n\r\n### Example `popular_tlds.txt`\r\n\r\n```\r\n\r\ncom\r\n\r\nnet\r\n\r\norg\r\n\r\nedu\r\n\r\n```\r\n\r\n### Example `disposable_domains.txt`\r\n\r\n```\r\n\r\nmailinator.com\r\n\r\n10minutemail.com\r\n\r\n```\r\n\r\n## Full Example\r\n\r\nHere's a more detailed example demonstrating all features:\r\n\r\n```python\r\n\r\nimport os\r\n\r\nfrom email_validator import EmailValidator\r\n\r\n# Initialize the validator with custom data files\r\n\r\nvalidator = EmailValidator(\r\n\r\n\u00a0 \u00a0 domains_file='data/popular_domains.txt',\r\n\r\n\u00a0 \u00a0 tlds_file='data/popular_tlds.txt',\r\n\r\n\u00a0 \u00a0 disposable_file='data/disposable_domains.txt'\r\n\r\n)\r\n\r\nemails = [\r\n\r\n\u00a0 \u00a0 \"valid.email@gmail.com\",\r\n\r\n\u00a0 \u00a0 \"invalid-email\",\r\n\r\n\u00a0 \u00a0 \"test@mailinator.com\",\r\n\r\n\u00a0 \u00a0 \"user@gnail.com\",\r\n\r\n\u00a0 \u00a0 \"user@gmail.cmo\",\r\n\r\n\u00a0 \u00a0 \"user@nonexistentdomain.xyz\"\r\n\r\n]\r\n\r\nfor email in emails:\r\n\r\n\u00a0 \u00a0 result = validator.validate(email)\r\n\r\n\u00a0 \u00a0 if result[\"valid\"]:\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 print(f\"{email} is valid!\")\r\n\r\n\u00a0 \u00a0 else:\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 print(f\"Error with {email}: {result['error']}\")\r\n\r\n```\r\n\r\n## Running Tests\r\n\r\nTo run the tests, use the following command:\r\n\r\n```sh\r\n\r\npython -m unittest discover\r\n\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Feel free to contribute to this project if you want to add new features, improve existing ones, or fix bugs.\r\n\r\n## Issues\r\n\r\nPlease raise and issue for bug reporst, feature requests or suggestions.\r\n## Author\r\n\r\nChukwuka Ibejih\r\n\r\nFor any questions or feedback, please contact [chukaibejih@gmail.com](mailto:chukaibejih@gmail.com).\r\n\r\n## Acknowledgements\r\n\r\nThis library uses the following third-party packages:\r\n\r\n- [Django](https://www.djangoproject.com/) for email validation\r\n\r\n- [Levenshtein](https://pypi.org/project/python-Levenshtein/) for string similarity calculations\r\n\r\n- [dnspython](https://www.dnspython.org/) for DNS queries\r\n\r\n\r\nIf you love this project, please consider giving me a \u2b50\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python library for validating and suggesting corrections for email addresses.",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/chukaibejih/email-validator"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90768a1e84a3e592e0120213a4ab94a8ed97d846967ea6a68f65d5b8f574fb50",
                "md5": "dcbf1a7a5b215ddd55d7fd3185fd0cd5",
                "sha256": "c454a1187e3446e23480b5e04fcf6a0977129f31ed4b005dc3ac3fe40e34aedd"
            },
            "downloads": -1,
            "filename": "email_safeguard-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dcbf1a7a5b215ddd55d7fd3185fd0cd5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 967448,
            "upload_time": "2024-08-07T14:41:08",
            "upload_time_iso_8601": "2024-08-07T14:41:08.798084Z",
            "url": "https://files.pythonhosted.org/packages/90/76/8a1e84a3e592e0120213a4ab94a8ed97d846967ea6a68f65d5b8f574fb50/email_safeguard-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c76c53f963e67cfbb5c4c9fcd352a72d0c65ade5aeb23e0a4e7395da257183df",
                "md5": "0551bbaada79f343dc83da8a87c71e54",
                "sha256": "f78bf2f2c914cd10f2b835e018015ee0b45ee71fc6b27a21c6510fbd26db320d"
            },
            "downloads": -1,
            "filename": "email_safeguard-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0551bbaada79f343dc83da8a87c71e54",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 966728,
            "upload_time": "2024-08-07T14:41:11",
            "upload_time_iso_8601": "2024-08-07T14:41:11.068530Z",
            "url": "https://files.pythonhosted.org/packages/c7/6c/53f963e67cfbb5c4c9fcd352a72d0c65ade5aeb23e0a4e7395da257183df/email_safeguard-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-07 14:41:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chukaibejih",
    "github_project": "email-validator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "email-safeguard"
}
        
Elapsed time: 0.32514s