Developing a typo3 extension which is generating output, presenting a link for an email address is no matter using the function getTypoLink(). But as soon, as you try to add a predefined subject with space characters to the mail and you have turned on the build in spam protection feature, this can lead into some trouble.
Your subject may be stripped at the first whitespace. Then you can try to urlencode() or rawurlencode() the subject before you add the parameter to the email address. But even this would fail, because there will be + or 0 characters be placed in the subject instead of the whitespaces.
Typo3 provides a more low level method to get the required infos for the email link generated and taking care for the spam protection configuration. This method is called getMailTo(mailAdrress, LinkText) and it returns an array with the mailto link at index 0 and the link text at index 1. This is the first step to the solution. But it still has one limitation. When you add a ‘?subject=my subject with spaces’ to the email link, the spam protection configuration will be annuled for the link text. so you might end up with the unprotected email address again.
The final solution will be to call getMailTo() twice. Once to generate the email link including the subject and another time to protect the link text. Afterwards you can pick up the best of the two arrays you have generated. The code snippet below shows an example of the solutions application.
$emailAddress.'?subject=Email subject with multiple words',
$mailInfosText = $this->cObj->getMailTo($emailAddress,$emailAddress);
$email = ''.$mailInfosText.'';