Jump to:

23355 Posts in 17838 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Email Obfuscation

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

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

Page: 1 2 3
Go to End
Author Topic: 3992 Views
  • ollyp
    Avatar
    Community Member
    3 Posts

    Email Obfuscation Link to this post

    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.

    Olly

  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Email Obfuscation Link to this post

    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 site.com/email/userid)?

    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: http://www.weberdev.com/get_example-4655.html

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Email Obfuscation Link to this post

    I take it you want something like this: http://www.braemoor.co.uk/software/obfuscator.shtml - Script at: http://www.braemoor.co.uk/software/_private/obfuscate.js

    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.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Email Obfuscation Link to this post

    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('my@email.com', 'direction');
    }

    Hope this helps.

    Sean

  • geist
    Avatar
    Community Member
    7 Posts

    Re: Email Obfuscation Link to this post

    When I add "function MyObfuscatedEmail()" to my Page_Controller and I call $MyObfuscatedEmail in my Page.ss, 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...?

  • Mo
    Avatar
    Community Member
    504 Posts

    Re: Email Obfuscation Link to this post

    Looks like a typo, should be:

    function MyObfuscatedEmail() {
    return Email::obfuscate('my@email.com', 'direction');
    }

  • geist
    Avatar
    Community Member
    7 Posts

    Re: Email Obfuscation Link to this post

    I have to apologize...

    Thank you.

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Email Obfuscation Link to this post

    Folks,

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

    Toby

    3992 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.