Small PHP library to valid email addresses using a number of methods.

Overview

Email Validator

Small PHP library to valid email addresses using a number of methods.

License Build Status Code Quality Downloads Github Stars

Features

  • Validates email address
  • Checks for example domains (e.g. example.com)
  • Checks for disposable email domains (e.g. mailinator.com)
  • Checks for role-based addresses (e.g. abuse@)
  • Checks for MX records (i.e. can receive email)

Install (using Composer)

composer require nojacko/email-validator:~1.0

Usage

Generalised Functions

  • isValid($email) Runs all the tests within this library. Returns true or false.
  • isSendable($email) Checks isEmail, isExample and hasMx. Returns true or false.

Specific Functions

If you want more control, use these functions seperately.

  • isEmail($email) Note: returns true or false only.
  • isExample($email)
  • isDisposable($email)
  • isRole($email)
  • hasMx($email)

These functions take a single argument (an email address) and return:

  • true, when function name is satisfied.
  • false, when function name is not satisfied.
  • null, when check is not possible, i.e. an invalid email is given.

Examples

$validator = new \EmailValidator\Validator();

$validator->isValid('[email protected]');              // true
$validator->isValid('[email protected]');                // false
$validator->isValid('[email protected]');             // false

$validator->isSendable('[email protected]');           // true
$validator->isSendable('[email protected]');             // true
$validator->isSendable('[email protected]');          // false

$validator->isEmail('[email protected]');             // true
$validator->isEmail('example@example');                 // false

$validator->isExample('[email protected]');           // true
$validator->isExample('[email protected]');            // false
$validator->isExample('example.com');                   // null

$validator->isDisposable('[email protected]');        // false
$validator->isDisposable('[email protected]');     // true
$validator->isDisposable('example.com');                // null

$validator->isRole('[email protected]');              // false
$validator->isRole('[email protected]');                // true
$validator->isRole('example.com');                      // null

$validator->hasMx('[email protected]');               // false
$validator->hasMx('[email protected]');                // true
$validator->hasMx('example.com');                       // null

Contribute

Contributions welcome!

Requirements

Add/Remove Disposable Domain

See the email-data-disposable project.

New Feature

If you're planning a new feature, please raise an issue first to ensure it's in scope. The aim is to keep this library small and with one specific purpose.

Other Contributions

For anything that isn't a new feature (bug fix, tests, etc) just create a pull request.

Testing

Test are all located in tests folder.

Run tests with phpunit. In root folder, execute phpunit in a CLI.

Versioning

Semantic Versioning 2.0.0

License

The MIT License (MIT). See LICENCE file.

Comments
  • Merged martenson/disposable-email-domains blacklist

    Merged martenson/disposable-email-domains blacklist

    Just asked the Martenson if I could merge the blacklist, because his one is a bit better ;) https://github.com/martenson/disposable-email-domains/issues/15

    opened by mipapo 4
  • Checks for MX, A, and AAAA DNS records

    Checks for MX, A, and AAAA DNS records

    Changed hasMx to hasDNS to reflect the semantic check for A and AAAA records in Validator.php. Updated README.md with hasDNS instead of hasMx.

    This is to reflect the fact that some email domains have no MX records but have an A or AAAA record. I borrowed this idea from egulias/EmailValidator source.

    opened by Ema4rl 3
  • Keeping PHP implementation apart from the domain list

    Keeping PHP implementation apart from the domain list

    Consider adding my disposable domain repo (https://github.com/martenson/disposable-email-domains) as a git submodule so we can work together on one list that is domain agnostic and you can continue here on your PHP validator implementation without the hassle of keeping the list up to date.

    opened by martenson 1
  • Email with name

    Email with name

    Hello! This is really tiny validator, but it will be great to pass validation for emails with names like Sender Name <[email protected]>

    opened by SilverFire 1
  • Invalid email addresses with space then underscore not being detected

    Invalid email addresses with space then underscore not being detected

    I have found that having a space then underscore, the regex doesn't see it as invalid. For example frank [email protected] is valid according to this library. I note that frank_ [email protected] is not valid so it's more than just looking for a space. Pull request #8 fixes this issue. Please merge and release a new version, thanks!

    opened by joshbmarshall 0
Magento 2 Email Catcher or Email Logger Module.

Magento 2 Module Experius email catcher / - logger

Experius 49 Dec 16, 2021
SendPortal - Open-source self-hosted email marketing, subscriber and list management, email campaigns and more

SendPortal includes subscriber and list management, email campaigns, message tracking, reports and multiple workspaces/domains in a modern, flexible and scalable application.

Mettle 1.2k Jan 4, 2023
Cross-language email validation. Backed by a database of over 38 000 throwable email domains.

Cross-language temporary (disposable/throwaway) email detection library. Covers 38038+ fake email providers.

Francois-Guillaume Ribreau 1.4k Jan 9, 2023
Library for using online Email providers

Stampie Stampie have been moved to the "Flint" organization in order to get a better collaborative flow. Stampie is a simple API Wrapper for different

Henrik Bjørnskov 32 Oct 7, 2020
Library for using online Email providers

Stampie Stampie is a simple API Wrapper for different email providers such as Postmark and SendGrid. It is very easy to use and to integrate into your

Stampie 288 Dec 31, 2022
Fetch is a library for reading email and attachments, primarily using the POP and IMAP protocols

Fetch Fetch is a library for reading email and attachments, primarily using the POP and IMAP protocols. Installing N.b. A note on Ubuntu 14.04 (probab

Tedious Developments 501 Jan 4, 2023
EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby

EmailReplyParser EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby.

William Durand 606 Dec 8, 2022
Send email across all platforms using one interface

Send email across all platforms using one interface. Table Of Content Requirements Installation Providers AmazonSES Mailgun Mailjet Mandrill Postmark

Omnimail 329 Dec 30, 2022
The classic email sending library for PHP

PHPMailer – A full-featured email creation and transfer class for PHP Features Probably the world's most popular code for sending email from PHP! Used

PHPMailer 19k Jan 1, 2023
PHP library for parsing plain text email content.

EmailReplyParser EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby.

William Durand 606 Dec 8, 2022
📧 Handy email creation and transfer library for PHP with both text and MIME-compliant support.

?? Handy email creation and transfer library for PHP with both text and MIME-compliant support.

Nette Foundation 401 Dec 22, 2022
PHPMailer – A full-featured email creation and transfer class for PHP

PHPMailer – A full-featured email creation and transfer class for PHP Features Probably the world's most popular code for sending email from PHP! Used

PHPMailer 19.1k Jan 2, 2023
A ready-to-use PHP script for sending Emails with an HTML Template will use a Gmail account as the sender and you will not need any email server. Powered by PHPMailer.

Gmail Email Sender by PHP A ready-to-use PHP script for sending Emails with an HTML Template will use a Gmail account as the sender and you will not n

Max Base 4 Oct 29, 2022
Mail sending module for Mezzio and Laminas MVC with support for file attachment and template email composition

This module provides an easy and flexible way to send emails from Mezzio and Laminas MVC applications (formerly known as Zend Expressive and Zend MVC). It allows you to pre-configure emails and transports, and then send those emails at runtime.

null 82 Jan 16, 2022
Omnisend: Ecommerce Email Marketing and SMS Platform

Omnisend Omnisend: Ecommerce Email Marketing and SMS Platform Version v1.x Support all PHP Version >=5.6 v2.x Support all PHP Version >=7.0 Installati

Hung Nguyen 3 Jan 6, 2022
Sending Email via Microsoft Exchange Web Services made Easy!

Send Mail via Exchange Web Services! Sending Email via Microsoft Exchange Web Services (EWS) made easy! Installation Install via Composer composer req

Raju Rayhan 19 Jul 19, 2022
Mailcoach is a self-hosted email list manager - in a modern jacket.

Welcome to Mailcoach Mailcoach is a self-hosted email list manager - in a modern jacket. It features: Subscribers and lists management Subscribe, doub

Spatie 3 Jan 31, 2022
An AngularJS / Laravel app - Keyword Based Email forwarder | read/write emails through IMAP

@MailTree Simple mail forwarder. Based on the specific email body/subject keywords forward mails to the list of predefined users. Install Imap Install

Dren Kajmakchi 4 Aug 21, 2018
Disposable email address validator for Laravel

Laravel Disposable Email Adds a validator to Laravel for checking whether a given email address isn't originating from disposable email services such

null 332 Dec 29, 2022