beastbytes/emailobfuscator
Widget to obfuscate email addresses
Maintainers
Package info
github.com/beastbytes/email-obfuscator
Type:extension
pkg:composer/beastbytes/emailobfuscator
Requires
- php: >=8.0
- yiisoft/arrays: ^3.0
- yiisoft/html: ^3.0
- yiisoft/view: ^8.0
- yiisoft/widget: ^2.0
Requires (Dev)
- consolidation/robo: ^4.0
- phpunit/phpunit: ^10.0
- roave/infection-static-analysis-plugin: ^1.0
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.0
- yiisoft/test-support: ^3.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
BSD-3-Clause ebc6cb2577bae188493ec4ea1491b0856b43d34c
- Chris Yates <chris.l.yates.woop@gmail.com>
This package is auto-updated.
Last update: 2026-06-14 17:15:40 UTC
README
Widget to obfuscate an email address to help prevent harvesting by spam bots.
If JavaScript is disabled on the client, the widget will output either a message or an obfuscated version of the email address.
If JavaScript is enabled the output is replaced with (by default) a mailto link showing (again by default) the email address. The content of the mailto link can be customised.
For license information see the LICENSE file.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist beastbytes/emailobfuscator
or add
"beastbytes/emailobfuscator": "^1.0"
to the require section of your composer.json.
Usage
Use this extension in a view.
To output the default message ("This e-mail address is protected to prevent harvesting by spam-bots")
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com' ]);
Output
JavaScript Disabled
<span id="w0">This e-mail address is protected to prevent harvesting by spam-bots</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To output a different message set content['obfuscated']
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'content' => ['obfuscated' => 'Enable JavaScript to see the email address'] ]);
Output
JavaScript Disabled
<span id="w0">Enable JavaScript to see the email address</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To output an obfuscated version of the email address set the obfuscators: "my dot address at example dot com"
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'obfuscators' => [' dot ', ' at '] ]);
Output
JavaScript Disabled
<span id="w0">my dot address at example dot com</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">my.address@example.com</a></span>
To set the content of the mailto link, set content['clear']
echo EmailObfuscator::widget([ 'email' => 'my.address@example.com', 'content' => ['clear' => 'by email'] ]);
Output
JavaScript Disabled
<span id="w0">This e-mail address is protected to prevent harvesting by spam-bots</span>
JavaScript Enabled
<span id="w0"><a href="mailto:my.address@example.com">by email</a></span>
