Remove tag a using php and leave only td text

0

I am using PHPMailer to send emails, but in the body of the email has a field (address) that is coming as a link (to the maps) to the recipient.

I've already used strip_tags () but it did not work. Locally it works, but when testo online does not work.

Code:

 $end = $_POST['endereco'];
 $enderecoFormatado= strip_tags($end, '<a>');

 $corpo = "<h1><table>       
    <tr>
      <td>Endereco: </td>
      <td>
        $enderecoFormatado
      </td>
    </tr>        
  </table>";


 $corpo = utf8_decode($corpo);
 $mail->msgHTML($corpo);
    
asked by anonymous 23.02.2018 / 18:00

1 answer

1

In general, you can not avoid this because the email client automatically adds links when it finds valid URLs in the body of the message.

However, there is a trick that tricks the system and does not add the links. Just put the addresses (URLs) between the <a></a> (without href or nothing, just <a> ) tags. Example:

<a>http://www.site.com</a>

It even works with email addresses:

<a>[email protected]</a>
  

Note: Tested successfully in Gmail and Hotmail.

    
23.02.2018 / 19:21