<p>I wrote a really quick Plugin for you to use that uses the <code>_encodeStringRot13</code> function from the Sprout guys to use on any variable you want in Craft. What the Plugin does is to give you a new Twig filter that you can apply like this <code>{{ entry.body|protectEmails }}</code> and voila! - all <code>&lt;a href="mailto:"&gt;</code> will be encoded in ROT13 (reference: <a href="http://snipplr.com/view/6037/" rel="nofollow">http://snipplr.com/view/6037/</a>) on output.</p>

<p>Download it here: <a href="http://www.naboovalley.com/craft/toolkit.rar" rel="nofollow">http://www.naboovalley.com/craft/toolkit.rar</a></p>

CC BY-SA 3.0
2016-02-09T09:16:06.777Z
Thanks, but they won't be mailto links to start with. Content authors will just type/copy the email address into the text field, so the filter needs to look for any xxx@xxx.xxx string and encode that.
Paul Frost
CC BY-SA 3.0
2016-02-09T08:23:31.183Z
2016-02-09T08:23:31.183Z
naboovalley
<p><a href="https://github.com/Propaganistas/Email-Obfuscator" rel="nofollow">This email obfuscation library</a> works really well for me, and I'm using a rich text field. Applies both to mailto links as well as unlinked email addresses.</p>

<p>You'll probably have to write a simple wrapper plugin to make it work as a twig extension. Also don't forget to include the library's JS file in the page's head so that it's loaded before it's needed.</p>

CC BY-SA 3.0
2016-04-28T17:59:33.757Z
2016-04-28T17:59:33.757Z
Kevin Smith
<p>I'm used to this feature in ExpressionEngine either natively or via the Auto Linker plugin, where you just wrap it around all the text fields. I've seen the <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/encode-email" rel="nofollow">Sprout Encode Email</a> addon but that doesn't search through text and apply it.
I don't mind if it doesn't create a mailto link, I just want to obfuscate every email address that appears in any of the text fields in a template.</p>

CC BY-SA 3.0
2016-02-09T00:41:20.077Z
What do you mean by "obfuscate", exactly? Can you give an example of how you want the email addresses to look?
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-02-09T09:13:06.993Z
I want it to convert any string of text that looks like an email address (xxx@xxx.xxx) within a text field into an encoded string to make it harder for robot harvesters. Look at the above link doc to see what the Sprout one does.
Paul Frost
<emails>
How to auto obfuscate email addresses in rich text field
# How to auto obfuscate email addresses in rich text field

(Asked by: username_0 on 2016-02-08)

I'm used to this feature in ExpressionEngine either natively or via the Auto Linker plugin, where you just wrap it around all the text fields. I've seen the [Sprout Encode Email](http://sprout.barrelstrengthdesign.com/craft-plugins/encode-email) addon but that doesn't search through text and apply it.
I don't mind if it doesn't create a mailto link, I just want to obfuscate every email address that appears in any of the text fields in a template.

**Tags:** emails

> **Comments:**
> **username_1**: What do you mean by "obfuscate", exactly? Can you give an example of how you want the email addresses to look?  
> **username_0**: I want it to convert any string of text that looks like an email address (xxx@xxx.xxx) within a text field into an encoded string to make it harder for robot harvesters. Look at the above link doc to see what the Sprout one does.  

---

## 2 answers

### Answer by username_2 on 2016-02-09. Score: 3

I wrote a really quick Plugin for you to use that uses the `_encodeStringRot13` function from the Sprout guys to use on any variable you want in Craft. What the Plugin does is to give you a new Twig filter that you can apply like this `{{ entry.body|protectEmails }}` and voila! - all  will be encoded in ROT13 (reference: <http://snipplr.com/view/6037/>) on output.

Download it here: <http://www.username_2.com/craft/toolkit.rar>

> **Comments:**
> **username_0**: Thanks, but they won't be mailto links to start with. Content authors will just type/copy the email address into the text field, so the filter needs to look for any xxx@xxx.xxx string and encode that.  

---

### Answer by username_3 on 2016-04-28. Score: 1

[This email obfuscation library](https://github.com/Propaganistas/Email-Obfuscator) works really well for me, and I'm using a rich text field. Applies both to mailto links as well as unlinked email addresses.

You'll probably have to write a simple wrapper plugin to make it work as a twig extension. Also don't forget to include the library's JS file in the page's head so that it's loaded before it's needed.


---

