Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Email Obfuscation

Go to End

17 Posts   5936 Views


Community Member, 3 Posts

14 September 2009 at 11:48pm

So I am trying to get some Email obfuscation, this is not for forms but to replace mailto: links.
I have tried the hidemailto module with no success so just want a sanity check on my new idea.

Linking to a redirect page?
Set up a redirect page where the redirect url is the mailto link.
Obviously this needs a separate page for each e-mail address, but will this work? If the redirect happens in the php there will be no source code with the address in plain text.
I have tried opening the page in text editors to get the source and they fail.
I know this is obviously not the best way to go about this, but I have no idea what other options I have.



Community Member, 283 Posts

15 September 2009 at 3:41am

I'm not sure where you're coming from. Do you want to automatically replace any entered email addresses in the CMS Content Editor with some sort of system? Or do you want to build a system you can statically link to from your pages (ie

I think the simplest thing would be to generate images with the email text in it and just insert those inline when needed. Here is an example to get your running:


Community Member, 253 Posts

15 September 2009 at 4:43am

I take it you want something like this: - Script at:

I reckon you have two options:

1. Create a new fieldtype and then either with JS in the CMS or just with the 'onSave' method or some such, store the obfuscated e-mail address.

2. In the content function simply do a preg_replace for all <a> with href="mailto:*" in and parse the e-mail address bit through the obfuscator function.


Forum Moderator, 922 Posts

18 September 2009 at 4:32pm

Edited: 27/10/2009 2:31pm

Have a look in the Email.php class in your SilverStripe installations.

There's a handy static function in there called "obfuscate". The first parameter to this function is the email address to obfuscate, the second is the method to obfuscate with. 'visible' is the default, but there's also a very handy one called 'direction' that is very good.

Use this for sending obfuscated emails to the templates from your controller. e.g.:

function MyObfuscatedEmail() {
	return Email::obfuscate('', 'direction');

Hope this helps.



Community Member, 7 Posts

27 October 2009 at 10:24am

When I add "function MyObfuscatedEmail()" to my Page_Controller and I call $MyObfuscatedEmail in my, Silverstripe only returns "Fatal error: Call to undefined method Email::obsfucate() in Page.php".

So, there are two possibilities:
1. This is not the way to.
2. I haven't understand Silverstripe yet

If its the second possibility: Who can help me...?


Community Member, 541 Posts

27 October 2009 at 12:09pm

Looks like a typo, should be:

function MyObfuscatedEmail() {
   return Email::obfuscate('', 'direction');


Community Member, 7 Posts

27 October 2009 at 4:03pm

I have to apologize...

Thank you.


Community Member, 97 Posts

31 October 2009 at 2:58pm


I'm looking for an example of the HTML you'd use when using this function.


Go to Top