Unwanted "!" notes in php html messages

I am using the php default email function to send html email messages. My code is:

//SENDMAIL

// multiple recipients
$to  = ''. $email .'' . ', '; // note the comma
$to .= 'adress@domain.com';


// subject
$subject = 'subject';

// message
$message = '
<html>
<head>
<title>Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257">
<style type="text/css">
body,td,th {
 font-family: Verdana;
 font-size: 12px;
}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
html table data ...... in html syntax
';

if(($b1 == "true" || $b2 == "true" || $b3 == "true" || $b4 == "true" || $b5 == "true" || $b6 == "true" || $b7 == "true" || $b8 == "true" || $b9 == "true" || $b10 == "true" || $b11 == "true" || $b12 == "true" || $b13 == "true" || $b14 == "true" || $b15 == "true" || $b16 == "true") && $enb == "true")
{
 $message .= 'link1<br>
 ';
}
if(($b1 == "true" || $b2 == "true" || $b3 == "true" || $b4 == "true" || $b5 == "true" || $b6 == "true" || $b7 == "true" || $b8 == "true" || $b9 == "true" || $b10 == "true" || $b11 == "true" || $b12 == "true" || $b13 == "true" || $b14 == "true" || $b15 == "true" || $b16 == "true") && $nlb == "true")
{
 $message .= 'link2<br> 
 ';
}
$message .='html body continued in html syntax
$message .= '</html>';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

// Additional headers
$headers .= 'To: ' . "\r\n";
$headers .= 'From: Sender <no-reply@domain.com>' . "\r\n";
$headers .= 'Cc: ' . "\r\n";
$headers .= 'Bcc: ' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

When a message is sent sometimes, the mystical does not always appear! characters in the middle of the text. For example: "Thank you for your letter" or "Ki, respect," and center. There seems to be no template in this, so I wanted to ask if this is a common error in php mail and how to overcome it?

Thank!

+3
source share
4 answers

Each line of the letter (998) has a limit on the maximum characters, which, it seems to me, depend on it. Use wordwrap to avoid these long lines.

+2

meta http-equiv = "Content-Type" content= "/HTML; Charset = -1257"

Content-type: text/html; charset=utf-8

utf-8 , utf-8, http://www.php.net/manual/en/function.mb-convert-encoding.php mb_convert_encoding utf-8.

mail($to, $subject, mb_convert_encoding( $message, "UTF-8"), $headers);
0

Use http://php.net/wordwrap to limit your lines to 80 characters and add an equal sign ( =) at the end of wrapped lines.

0
source

I just experienced the same thing with VB Script on an ASP page. The solution is the same: split the HTML string in VB with vbNewLine.

0
source

Source: https://habr.com/ru/post/1776469/