Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Assemble and disassemble email for spam protection

In our footer we have an email that we are pulling from the database, in php blade it will look like this:

<a href="mailto:{{ $email }}">{{ $email }}</a>

I need to protect him from spambots.

I heard that in php it can be split and then assembled through a javascript, and it will look something like this:

<a href="" data-first="" deta-second="">{{ $email }}</a>

Where data is the parts of the email itself. But I didn't understand how to separate it and then collect it. Can someone tell me how to do this?

Or tell me similar features, how to protect against spambots.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Web scrapers will usually only download plain HTML response.

In this case you will be protected as long as your code doesn't contain email as plain text and email is put back together onload

Some might even execute JS when scraping your page.

To avoid this you can require user to press something to put email together. I made a quick example:

function showEmail (element) {
    const infoData = document.querySelector('[data-target="'+element.id+'"]').dataset;
    const mail = infoData.p1 + '@' + infoData.p2 + "." + infoData.p3;
    element.href = "mailto:"  + mail;
    element.text = mail;
}
<a href="" id="mailOutput1" onclick="showEmail(this)">Send Email</a>
<!--p1, p2, p3 are filled in PHP -->
<span data-target="mailOutput1" data-p1="john.doe" data-p2="example" data-p3="com"></span>

about 4 years ago · Juan Pablo Isaza Relatório

0

there are nothing to do with PHP with that as PHP is a server-side language.

you can do this with Javascript ( will use jquery here to simplify it )

this will append the email which is stored in data-mail to the href attribute and once your client clicks it the attribute will be removed again.

<a class="email" data-mail="{{ $email }}">{{ $email }}</a>

$('.email').click(function () {
    let t = $(this);

    t.attr('href', 'mailto:' + t.data('mail'));

    setTimeout(() => t.removeAttr('href'), 1);
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda