Hide Mailto: link

I have a different letter mailto: the email address on my site, which now falls into various combines, and then I spam.

Can someone help me in creating PHP code for the following:

<a href="mailto:info@company.com">info@company.com</a>

To prohibit the collection of addresses and equally, can I use this script for different email addresses displayed on the site?

thank

+3
source share
9 answers

The best solution I have found is to use a bit of javascript. You call the function, passing it to the address, and it prints a link for you. Since most bots do not handle javascript, this should work in most cases:

<script type='text/javascript'>
    function email(name, domain, withlink) {
        var addr = name + '@' + domain;
        if(withlink) {
            document.write('<a href="mailto:' + addr + '">' + addr + '</a>');
        } else {
            document.write(addr);
        }
    }
</script>

And then when you want to type the email address on the site:

<script>email('myuser', 'mydomain');</script>

, :

<script>email('myuser', 'mydomain', true);</script>

. , . , , , .

+2

, JavaScript document.write(). , , . , "" ( , , ).

- , ( honeypot , , IP- ). onClick , , . , .

<a href="mailto:fake@example.com" 
   onClick="this.href=this.href.replace('fake', 'real')">
Send Us E-mail</a>

"fake@example.com" "" "", .

, , - . script. , . , , , .

+3

Javascript. -

<script>
document.write('<a href="mailto:inblahfo@company.com">inblahfo@company.com</a>'
.replace(/blah/g, ''));
</script>
+1

Hive Enkoder mailto:

http://hivelogic.com/enkoder/

+1

:

function obfuscate_email($email) {
    $obf = '';
    for($i = 0; $i < strlen($email); $i++) {
        $obf .= '&#' . ord($email[$i]) . ';';
    }
    return $obf;
}

echo '<a href="mailto:' . obfuscate_email('info@company.com') . '">' . obfuscate_email('info@company.com') . '</a>';

HTML:

<a href="mailto:&#105;&#110;&#102;&#111;&#64;&#99;&#111;&#109;&#112;&#97;&#110;&#121;&#46;&#99;&#111;&#109;">&#105;&#110;&#102;&#111;&#64;&#99;&#111;&#109;&#112;&#97;&#110;&#121;&#46;&#99;&#111;&#109;</a>

:

info@company.com

+1

- :)

-:

<script type="text/javascript">
  var part1 = "me";
  var part2 = "mydomain.com";
  var part3 = "Click Here to Send";
  document.write('<a href="mai' + 'lto:' + part1 + '@' + part2 + '">');
  document.write(part3 + '</a>');
</script>

:

0

recaptca. , . , . - API ( -)

- heres mailhide

0

, aemail.com:

@email - , , URL-, mailto-url .

aemail.com URL-, mailto. , , URL- mailto - aemail.com. API / URL- .

:

<a href="mailto:info@itee.com">Contact</a>

<a href="https://aemail.com/q2">Contact</a>

.

0

Source: https://habr.com/ru/post/1782943/


All Articles