How to show email addresses on the website to avoid spams?

后端 未结 12 1074
醉酒成梦
醉酒成梦 2020-12-23 19:18

I show email on my website as following

 Email

But I read the following while analysing

相关标签:
12条回答
  • 2020-12-23 19:32

    There are multiple different choices for hiding emails on websites, commonly using either the HTML entity version of the email address (as Aziz-Saleh suggested), but from an actual web design point of view, just putting the email address like that on a website isn't the most user friendly thing to do.

    For instance, the mailto: link automatically triggers the browser to open the user's Email Application of choice - but consider this. Not everybody has a dedicated email application. For instance, I don't use Outlook (I'm a Windows user), and unless I have Windows Live Mail installed, my computer can't open that link. I think Chrome can open the links into GMail if you're signed in, but I would need to check that.

    Ultimately, by using mailto:, you are potentially alienating a portion of your userbase that will not be able to use that link in the first place.

    I would suggest using email forms, and there are plenty of easy-to-follow tutorials available for both PHP and your language of JSP, such as this link here: Sending Email in JSP and even on StackOverflow

    By using your server to send the email, you get tighter control over how the email is generated, what data the user is allowed to put in, and you could even send them a return email (generated by the server) to confirm that you have received their message. This is a tried-and-tested real-world method of allowing customers and visitors to contact you, whilst still giving you protection and control over the entire process.

    TL;DR: Raw mailto: links might alienate people without dedicated email programs, whereas if you use JSP forms, you can control how they contact you, with what information (you can use fields and the HTML5 required attribute to mandate certain input fields) and you can even respond with a do-not-reply email so they know their message was heard (just don't forget to ask for their email address)

    0 讨论(0)
  • 2020-12-23 19:32

    2020 (and potentially beyond) solution:

    1. Register with Formspree, a free platform that forwards form data to an email of your choosing. Be sure to register using the email address on which you want to receive submissions.
    2. Copy the unique Formspree endpoint that gets generated.
    3. Create a contact form with this endpoint.

    Congrats! Your email is officially masked from bots.

    0 讨论(0)
  • 2020-12-23 19:33

    Well, you can figure out a different way every day. Here's one using jQuery.

    <a class="mail" href="mailto:john@badmail.mydomain.com">e-mail</a>
    

    Then handle the click with jQuery.

    $('a.mail').on('click', function(){
        var href = $(this).attr('href');
        $(this).attr('href', href.replace('badmail.', ''));
    });
    

    The reason I like this is that I can let the spammers spam the dummy mail domain thinking they got yet another e-mail harvested. If I was maintaining my own spam filter, I could collect samples to my bad bucket.

    Also, this approach allows you to render the page quite clean with dynamic data and simply have the javascript snippet only once on the whole site to handle the real user clicks.

    Works also on mobiles.

    0 讨论(0)
  • 2020-12-23 19:33

    Yeah it means use a php form for visitors to contact you through. It is much safer and stops bots sending emails to you like thousands of times. Look around Google for a contact form tutorial there will be plenty!

    A tutorial will tell you to use php and so when the user fills out a form it will be emailed to you with the details they filled out in the form. However most forms use like a "Captcha" entry and it stops the bots, almost like a "Are you Human?" test.

    Hope this helps.

    0 讨论(0)
  • 2020-12-23 19:44

    Personally, I came up with this, pretty straightforward and kinda funny, I throw this code where I want my email address to appear:

    <script>(function whatever(){var s='@',n='nabil',k='kadimi.com',e=n+s+k,l='<a href=mailto:{{spam@cia.gov}}>{{spam@fbi.gov}}</a>'.replace(/{{.+?(}})/g,e);document.write(l)})()</script>
    

    Expanded

    <script>
        (function whatever() {
            var s = '@'
                , n = 'nabil'
                , k = 'kadimi.com'
                , e = n + s + k
                , l = '<a href=mailto:{{spam@cia.gov}}>{{spam@fbi.gov}}</a>'.replace(/{{.+?(}})/g, e)
            ;
            document.write(l);
        })();
    </script>
    

    Demo

    <script>(function whatever(){var s='@',n='nabil',k='kadimi.com',e=n+s+k,l='<a href=mailto:{{spam@cia.gov}}>{{spam@fbi.gov}}</a>'.replace(/{{.+?(}})/g,e);document.write(l)})()</script>

    0 讨论(0)
  • 2020-12-23 19:46

    Solution 1:

    You can use many publicly available email address encoders like (first result on google):

    http://www.wbwip.com/wbw/emailencoder.html

    This encodes the emails into their character entity value, this will require more logic form scrapers to decode it.

    So an email like: test@gmail.com becomes &#116;&#101;&#115;&#116;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109; which can be used in a mailto as well.

    Solution 2:

    Use an online email to image converter (again first result on google):

    http://www.email2image.com/Convert-Email-to-Image.aspx

    To make it as an image. Other services enable you to do this automatically via an API like:

    https://www.mashape.com/seikan/img4me-text-to-image-service#!endpoint-Main

    0 讨论(0)
提交回复
热议问题