[imp] Strange error message from server while stripping attachment

Richard Heggs richard.heggs at nottinghamcity.gov.uk
Thu Nov 27 02:54:16 PST 2003


Quoting Jan Schneider <jan () horde ! org>:

>Did anybody ever see this error message from the imap server:
>"Message contains bare newlines"
>
>This happened with one message that I wanted to strip an attachment from,
>while it was to be written back to the server.

/me cackles with glee

It's taken me a few days, but I've tracked this down.  The problem was that
$message->setContents() was appending a bare '\n' to the message that is to
be inserted in place of the stripped attachment.  I think this is incorrect
because the correct newline sequence is appended by $message->toString()
instead.  The result was a '\n\r\n' instead of '\r\n', which caused Cyrus
to sulk.


Patch below:

cvs diff -u Message.php
Index: Message.php
===================================================================
RCS file: /var/rsync-horde/imp/lib/Message.php,v
retrieving revision 1.138
diff -u -r1.138 Message.php
--- Message.php 1 Nov 2003 02:00:43 -0000       1.138
+++ Message.php 27 Nov 2003 10:42:18 -0000
@@ -342,7 +342,7 @@
         $message = $contents->getMIMEMessage();
         $oldPart = $message->getPart($partid);
         $newPart = new MIME_Part('text/plain');
-        $newPart->setContents('[' . _("Attachment stripped: Original
attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "'
. $oldPart->getName(false, true) . '"]' . "\n");
+        $newPart->setContents('[' . _("Attachment stripped: Original
attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "'
. $oldPart->getName(false, true) . '"]');
         $message->alterPart($partid, $newPart);

         /* We need to make sure we add "\r\n" after every line for

--
Richard Heggs
Systems Analyst
Nottingham City Council


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


######################################################################
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of Nottingham City Council unless specifically
stated. If you have received it in error, please delete it from your system,
do not use, copy or disclose the information in any way nor act in reliance
on it and notify the sender immediately. Please note that Nottingham City
Council monitors e-mails sent or received. Further communication will
signify your consent to this.
######################################################################


More information about the imp mailing list