Search code examples
phpmailto

mailto php removing new line characters


I'm using a mailto link to send e-mail with a php string variable inside it as follows:

'Would you like to E-mail stakeholders? <a class="emailLink" href="mailto:stakeholders?subject=Alert '.$ticket.'&body=Experience:  %0D%0A'.$exp.'">Review and Send!</a><br><br>';

I discovered that in the e-mail client it prints it out like:

Experience:  
Th Experience should contain:\r\n\r\nImpact\r\nHow to replicate\r\nComprehensive notes

So I tried:

$charactersToRemove = array("\r\n","\n","\r");
$replaceWith = "%0D%0A";
$exp = str_replace($charactersToRemove,$replaceWith,$exp);

Which doesn't seem to make a difference...Can someone tell me why? Thanks.


Solution

  • Can you post more of your code to show how $exp was assigned it's value?

    I've edited out my answer until I can provide better help.

    EDIT: Can you seriously try using "\r\n" with \" to escape "'s instead, just in case PHP is somehow localizing %0D$0A in your HTML output? What does the source of your page look like?