I am using the PHPMailer library integrated in Joomla 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.
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?
Use chunk_split. This function was designed for tasks like yours and even its default (split at 76 chars) says so.
So your code will be
$mail2send->setSubject($mail->subject);
$mail2send->IsHTML(true);
$mail2send->setBody(chunk_split($mail->body));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With