My PHP mail() script changes the !
exclamation mark on some email clients such as hotmail to %21
when the !
is in a tag in the email body.
Here's my script
$to = "myemail@outlook.com";
$subject = "Password Reset";
$body = "<a href=\"http://example.com/#!/page\">Link 1</a>
<br><br>
Without href: http://example.com/#!/page - regular text
";
$headers = "From: no-reply@example.com
";
$headers .= "Reply-To: no-reply@example.com
";
$headers .= "Return-Path: no-reply@example.com
";
$headers .= "X-Mailer: PHP5
";
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=utf-8' . "
";
mail($to,$subject,$body,$headers);
So in the script above, the !
is changed to %21
only when it's a link, the regular text keeps it as /#!/
instead of transforming it to /#%21/
How would I go about fixing this issue so it doesn't change to %21
?
Some characters are encoded because they are not valid URLs. In your case URL code points are replaced with percent-encoded byte %
.