We have a website with restricted access (only for exclusive members) coded in PHP.
On the Contact page we have a bunch of mailto
links, for example:
<a href="mailto:Name SURNAME <address@domain.com>">address@domain.com</a>
If a visitor clicks on one of the links, it does the usual stuff (opens a new email in Thunderbird with the To: field correctly filled in).
The problem is when a visitor right-clicks on one of the links, selects "Copy email address" and then pastes it in the To: field or wherever (even in a document), in which case the result would be:
Name%20SURNAME%20%3Caddress@domain.com%3E
instead of
Name SURNAME <address@domain.com>
I've been searching for a solution for hours and already tried rawurlencode(), urlencode()
and other possible tricks, with absolutely no effect.
Can some of you please help me?
Here is the PHP code that generates the link:
<?php echo '<a href="mailto:'.$name.' <'.$email.'>'.'">'.$email.'</a>'; ?>
//where $email is a valid email address
//and $name is plain text (usually two words with a space character between)
I believe you're trying to do something that simply cannot be done. I understand the idea but... it's not a thing.
I found no docs saying that you can put a name and enclose the email address in <>.
You can of course do:
<a href="mailto:address@domain.com">address@domain.com</a>