Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda