The situation is the following. I stored a plain text email in MySQL containing linebreaks as . When my php script needs to send the mail it first fills in some parameters with
sprintf
and then the mail is sent with the standard mail()
function.
The problem I encounter is that the email client (thunderbird in my case) displays these linebreaks instead of interpreting them.
To test my script I hardcoded a sentence in the mail. When I do this the mail is interpreted correctly. My first tought was that MySQL escapes the backslashes, so I tried to do a str_replace("\\\\", "\\", $str)
but this doesn't help.
I'm obviously making a wrong assumption or stupid error, but I don't see it. What could be the problem?
try to replace it like this str_replace(' ', " "); It might solve your problem if the characters are saved in you message as four seperate characters. If you have inputted them using for example phpmyadmin they will be saves as 4 characters and not 2 characters as you expect.
Hope it helps!
Try using var_dump to print the message, this might reveal better information on the value of the string.
Perhaps use this to ty and remove the slashes:
stripslashes($str);