We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: MD Spam Me Not, alternative to using {encode} for hiding or masking email addresses

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I know EE has the built in “encode” for masking email addresses but I’m one of those people who really like things to work whether or not the user has Javascript enabled. My goal was to make port an email obfuscator that worked even with Javascript disabled.

I just started using EE for most sites. Before, I used to have a config.php file that had all my handy functions in it - one of which was obfuscateEmail(); which ran a bit of PHP (see http://www.zapyon.de/ for the basis of what is happening in this plugin) to encode the email address in decimal or hexadecimal mode. May not be the most robust email masking, but it has worked for me on numerous sites, and I’ve never had a client say they were getting too much spam. I wanted this to work in my EE sites, so I wrote my first plugin! (cue sound of 1 hand clapping…)

Description The tag has three six parameters:

  1. email - The email address to obfuscate. [REQUIRED]
  2. mode - 1 or 2. 1 = decimal mode and 2 = Hexadecimal [OPTIONAL, defaults to 1]
  3. text - Text to display if different than the email address [OPTIONAL, defaults to showing the email address]
  4. title - OPTIONAL
  5. subject - OPTIONAL
  6. class - OPTIONAL

Example usage (full):

{exp:md_spam_me_not email="ee@masugadesign.com" mode="1" title="My Title" 
class="nocion email" subject="EE Inquiry" text="Email Ryan for more info."}

Example usage (basic):

{exp:md_spam_me_not email="ee@masugadesign.com"}

Hope it works for you.

More info for this plugin (and a link to download) is now located over at its designated page at masgadesign.com: http://www.masugadesign.com/the-lab/scripts/spam-me-not/

       
Cocoaholic's avatar
Cocoaholic
445 posts
16 years ago
Cocoaholic's avatar Cocoaholic

Thanks mdesign, works like a charm!

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

Thanks, Cocoaholic. You were nice enough to add a title attribute to the plugin, so I incorporated that and put out version 1.0.2, available in the first post.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
16 years ago
ExpressionEngineer's avatar ExpressionEngineer

/me claps three hands.

Well done, both you guys!

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Looks useful. Thanks as lot.

       
mhulse's avatar
mhulse
329 posts
15 years ago
mhulse's avatar mhulse

Hey, thanks for this!

I had my own php function for this sort of thing, but it was not working when I set my template to parse PHP on INPUT… Your plugin saved me a bit of dev time!

Keep up the great work mdesign! 😊

Cheers, M

       
cmod's avatar
cmod
1 posts
15 years ago
cmod's avatar cmod

Perfect, just what I was looking for!

       
Angie Herrera's avatar
Angie Herrera
363 posts
15 years ago
Angie Herrera's avatar Angie Herrera

This almost works for me. Was wondering if it’ll work in weblog fields (custom or otherwise)?

.angie

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

It should work, if you wrap the field you’re outputting with allow_eecode (another plugin). For example, if you have a huge body area that might have a few emails in there, instead of just putting

{body}

on your template, wrap that with:

{exp:allow_eecode}{body}{/exp:allow_eecode}

Then, anytime you’re using spammenot in that body field, it should get parsed correctly.

       
narration's avatar
narration
773 posts
15 years ago
narration's avatar narration

Thanks, mdesign - a nice contribution indeed.

And just noticed, you made this a while ago. Good to find it 😉.

Kind regards, Clive

       
E P Alton's avatar
E P Alton
55 posts
15 years ago
E P Alton's avatar E P Alton

This works great!

Any way of adding a “message body” parameter in the future would make it even better.

Thanks very much!

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

How would you envision using the message body? Like this:

{exp:spammenot email="you@email.com" mode="1" 
title="My Title" class="nocion email" subject="EE Inquiry" 
text="Email Ryan for more info."}If you have text that should go in the message body, 
it should go in here (between opening/closing tag), and we might have less trouble 
with weird characters here like ' or ", among others.{/exp:spammenot}

or like this:

{exp:spammenot email="you@email.com" mode="1" 
title="My Title" class="nocion email" subject="EE Inquiry" 
text="Email Ryan for more info." message_body="If you have text that should go in the 
message body, it should go in here right in a parameter), but we might have trouble 
with weird characters here like \\' or \\", among others - you might have to escape them."}

I feel like the first way would be the way to go, in case you had a long message that might have a bunch of tricky characters in it.

       
E P Alton's avatar
E P Alton
55 posts
15 years ago
E P Alton's avatar E P Alton

I’d gladly use either method but I suppose the first one is more straightforward (without having to escape certain characters).

       
RJB's avatar
RJB
35 posts
15 years ago
RJB's avatar RJB

Unfortunately, I’ve found that [as of version 1.0.3 - 15 September 2007] this plugin does not work with entries or custom weblog fields that use Textile formatting, but it does work with Markdown and/or SmartyPants’ text filters.

What happens with Textile is that the anchor code is output, but the e-mail address is not filled in so the code becomes:

<a href="mailto:"></a>

Markdown doesn’t seem to have a problem understanding the SpamMeNot syntax and outputs the code correctly:

<a href="mailto:user@domain.com">user@domain.com</a>
       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.
Unfortunately, I’ve found that [as of version 1.0.3 - 15 September 2007] this plugin does not work with entries or custom weblog fields that use Textile formatting…the anchor code is output, but the e-mail address is not filled it so the code becomes
<code><a href="mailto">

Have you tried it with single quotes, and with the most basic parameter(s)? I found that EE’s native {encode} doesn’t work with Textile either (in my experience) unless you don’t use any quotes.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.