字符串太长| 使用chunk_split

I have a heredoc var. in php and sending it via POST to an mail.php - everything worked fine, but since web.de and gmx.net are such tools they won´t accept my mails "String too Long 500..." - using chunk_split solved the problem:

$text1 = chunk_split($text1, 1212,"
");

But now the layout is screwed up sometimes. So instead of Hello there... It makes an empty space Hello t here...

Any ideas?

It depends on the type of content.

If your content is HTML, one way to handle it is to run the content through tidy::repairString.

If your content is text (without a structure and formatting language), breaking long lines during mail transfer is one of the things quoted-printable encoding does. Run your content through that. Send your message with a header named Content-Transfer-Encoding with value QUOTED-PRINTABLE. Mail clients will automatically put the content back together before displaying it.