karancan's solution should work, but the root cause is what Hobo was saying. The SMTP protocol requires that lines be limited to 1000 characters (or really 998 characters plus a CR-LF). If your line is longer than 1000 characters, a CR-LF will be inserted every 998 characters.
So if you're building up your $message with a bunch of $message .= "more text";
you'll encounter this error once that line is greater than 900 characters long. It's confusing though because the spaces seem to be intermittent, particularly if you're building up an HTML message because sometimes the linebreaks will appear in perfectly benign locations.
The simple solution is to add a \r\n\
to the end of lines.
Interestingly, these forms work:
$message .= "<tr><td>1</td><td>2</td>\r\n";
$message .= '<tr><td>1</td><td>2</td>'."\r\n";
But this does not:
$message .= '<tr><td>1</td><td>2</td>\r\n';
The \r\n
must be surrounded by double quotes, otherwise the characters will just get added to the text instead of creating a carriage return/line break.
@karancan is correct though, and you can skip adding the \r\n
's if you base64 encode your messages, and add the required header.