masroore / mailcheck-php
Reduce misspelled email addresses in your PHP apps.
Installs: 4 160
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1 || ^8.2
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
The PHP library that suggests a right domain when your users misspell it in an email address. See the original at https://github.com/mailcheck/mailcheck.
When your user types in "user@gmil.con", Mailcheck will suggest "user@gmail.com".
Mailcheck will offer up suggestions for second and top level domains too. For example, when a user types in "user@hotmail.cmo", "hotmail.com" will be suggested. Similarly, if only the second level domain is misspelled, it will be corrected independently of the top level domain.
Installation
Requires PHP 8.1+
You can install the package via composer:
composer require masroore/mailcheck
Usage
> $mailcheck = new Kaiju\Mailcheck\Mailcheck(); > print_r($mailcheck->suggest("user@gmil.con")); # Kaiju\Mailcheck\EmailSuggestion Object # ( # [fullAddress] => user@gmail.com # [originalAddress] => user@gmil.con # [account] => user # [domain] => gmail.com # )
Returns null
if no suggestion:
> $mailcheck->suggest("user@hotmail.com") # => null
Domains
Mailcheck has inbuilt defaults if the domains
, secondLevelDomains
or topLevelDomains
options aren't provided. We still recommend supplying your own domains based on the distribution of your users.
Adding your own Domains
You can replace Mailcheck's default domain/TLD suggestions by supplying replacements:
$mailcheck->setDomains(['customdomain.com', 'anotherdomain.net']); // replaces existing domains $mailcheck->setSecondLevelDomains(['domain', 'yetanotherdomain']); // replaces existing SLDs $mailcheck->setTopLevelDomains(['com.au', 'ru']); // replaces existing TLDs
Contributing
Let's make Mailcheck awesome. We're on the lookout for maintainers and contributors.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Maintainers
- Dr. Masroor Ehsan, Author.
License
Licensed under the MIT License.