Php mail () function changes characters and removes back breaks

this is what i have:

$msg = "1'2 ’3"4 "5"6 7~8!9@10#11$12%13^14&15*16(17)18}19{20"21:22?23>24<25 ";
mail("myemail@example.com","My subject",$msg);

when i receive an email i get the following:

1&#039;2 ’3&quot;4 "5"6 7~8!9@10#11$12%13^14&amp;15*16(17)18}19{20&quot;21:22?23&gt;24&lt;25

so it changes characters to html, i think? any ideas? I need the received letter to contain exactly what I stored in $ msg.thank you

he also removed the back breaks that I had. in db the field has reverse gaps, it is saved as follows:

Hello $name

welcome to $websitename 

thank you, management

this is a chrome example, but as you can see there are two blank lines. when an email is sent, those back-offs are ignored and everything is fine if there are any thoughts.

+5
source share
2 answers

Try adding headers, for example:

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);

See here: PHP mail ()

+4
source

base64 , :

$msg = "1'2 ’3\"4 "5"6 7~8!9@10#11$12%13^14&15*16(17)18}19{20\"21:22?23>24<25";

$body = chunk_split(base64_encode($msg));

mail("myemail@example.com", "My subject", $body, "Content-Transfer-Encoding: base64");

; , Outlook, , , .

HTML- , .

+2

All Articles