https://github.com/spatie/email-concealer
Conceal e-mail addresses in a string by replacing their domain
https://github.com/spatie/email-concealer
developer-tools email obfuscation security
Last synced: 10 months ago
JSON representation
Conceal e-mail addresses in a string by replacing their domain
- Host: GitHub
- URL: https://github.com/spatie/email-concealer
- Owner: spatie
- License: mit
- Created: 2017-04-20T16:15:15.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T13:00:07.000Z (over 4 years ago)
- Last Synced: 2025-04-22T20:47:00.121Z (about 1 year ago)
- Topics: developer-tools, email, obfuscation, security
- Language: PHP
- Homepage: https://spatie.be/opensource/php
- Size: 117 KB
- Stars: 53
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
[
](https://supportukrainenow.org)
# Conceal e-mail addresses in a string
[](https://packagist.org/packages/spatie/email-concealer)
[](https://travis-ci.org/spatie/email-concealer)
[](https://styleci.io/repos/88886061)
[](https://scrutinizer-ci.com/g/spatie/email-concealer)
[](https://packagist.org/packages/spatie/email-concealer)
Conceal e-mail addresses in a string by replacing their domain. Useful for concealing up production data—like MySQL dumps—so you can use it locally without worrying about having real addresses on your system.
```php
use Spatie\EmailConcealer\Concealer;
$concealer = Concealer::create();
$concealer->conceal('info@spatie.be');
// "info@example.com"
```
## Support us
[
](https://spatie.be/github-ad-click/email-concealer)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Postcardware
You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).
## Installation
You can install the package via composer:
``` bash
composer require spatie/email-concealer
```
## Usage
To conceal a string, create an `Concealer` instance. and call the `conceal` method.
```php
use Spatie\EmailConcealer\Concealer;
$concealer = Concealer::create();
$concealer->conceal('info@spatie.be');
// "info@example.com"
```
The concealer processes every e-mail address it finds in the string. It will ensure that there aren't any unwanted duplicates if the local-part is the same.
```php
$concealer->conceal('info@spatie.be,info@foo.com,info@bar.com');
// "info@example.com,info-1@foo.com,info-2@bar.com"
```
Equal e-mail addresses will always conceal to the same concealed address.
```php
$concealer->conceal('info@spatie.be,info@foo.com,info@spatie.be');
// "info@example.com,info-1@example.com,info@example.com"
```
If you want to use a different domain than `example.com`, use the `domain` method to set a new one.
```php
$concealer = Concealer::create()->domain('foo.com');
echo $concealer->conceal('info@spatie.be'); // "info@foo.com"
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security
If you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.
## Credits
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)
## About Spatie
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.