Avoiding 500 line limit exceeded error while sending emails
===

I am using the [PHPMailer library integrated in Joomla][1] for an email component in Joomla. It does work quite well, however I am having an issue with users running the script with 1and1 mail servers. They can get errors like that:

> 2012-06-14 18:20:34 u65913791 1x1et0-1RocCH2xzU-00qzkq EE transaction error after sending of mail text: msmtp.kundenserver.de[172.19.35.7] **500 Line limit exceeded**

Another example from a different user:

> SMTP error from remote mail server after end of data:
host mx00.1and1.co.uk [212.227.15.134]: **500 Line limit exceeded**

The line limit is not about how many lines but how many characters are actually used in a single line which 1and1 limits to 10240 characters (support answer) - which is actually 10 times more than required in [RFC 2822][2].

I assume the issue is caused by using "wrong" line seperators when the emails is submitted so that the whole email reaches the email server as a single line. I guess that I need to make sure to insert line breaks in my script as PHPMailer fails do so.

Currently I am just receiving the HTML content from a WYSIWYG-editor and put into the PHPMailer object:

    // snip, $mail2send is the JMail instance, which inherits PHPMailer
    $mail2send->setSubject($mail->subject);
    $mail2send->IsHTML(true);
    $mail2send->setBody($mail->body);	
    // snip

How can I insert the appropiate line breaks?

  [1]: http://www.php.joomlademo.de/nav.html?libraries/phpmailer/phpmailer.php.source.html
  [2]: http://www.ietf.org/rfc/rfc2822.txt