beastbytes/emailobfuscator

Widget to obfuscate email addresses

Maintainers

👁 BeastBytes

Package info

github.com/beastbytes/email-obfuscator

Type:extension

pkg:composer/beastbytes/emailobfuscator

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2023-06-29 14:43 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause ebc6cb2577bae188493ec4ea1491b0856b43d34c

  • Chris Yates <chris.l.yates.woop@gmail.com>

emailwidgetemail addressobfuscationobfuscate

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>