What is the best practice for sending a link via email using PHP to ensure it displays correctly?

When sending a link via email using PHP, it's important to ensure that the link displays correctly in the recipient's email client. To do this, you should encode the link using urlencode() to handle any special characters and format it properly within the email body. Additionally, you can use HTML formatting to make the link clickable for the recipient.

<?php
$link = 'https://www.example.com/page?param1=value1&param2=value2';
$encoded_link = urlencode($link);

$email_body = "Click <a href='{$encoded_link}'>here</a> to visit our website.";

// Send email with $email_body as the message body
?>