php imap_append script not working

mistub mistub at
Thu Oct 17 16:50:59 EDT 2013

Hi all

wanted to append an attachment directly to imap⁻mailbox via php but got 
the following error (sending the upper part without attachment works):

PHP Notice:  Unknown: Message contains bare newlines (errflg=2) in 
Unknown on line 0

For courier-imap-Server the script works with attachment. Here's the 
script (thx to )



if ($mbox=imap_open( $authhost, $user, $pass))
     $dmy=date("d-M-Y H:i:s");
     $ouv=fopen ("$file", "rb");$attachment=fread ($ouv, filesize 

     $boundary = "------=".md5(uniqid(rand()));

     $msg = ("From: foo at\r\n"
         . "To: foo at\r\n"
         . "Date: $dmy\r\n"
         . "Subject: app-28hjwer0923409wuer09w34\r\n"
         . "MIME-Version: 1.0\r\n"
         . "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"
         . "X-App-Type: application/\r\n"
         . "X-App-Mime-Version: 3\r\n"
         . "\r\n\r\n"
         . "--$boundary\r\n"
         . "Content-Type: text/html;\r\n\tcharset=\"ISO-8859-1\"\r\n"
         . "Content-Transfer-Encoding: 8bit \r\n"
         . "\r\n\r\n"
         . "This is a App object.\r\n"
         . "\r\n\r\n"
         . "--$boundary\r\n"
         . "Content-Transfer-Encoding: 8bit\r\n"
         . "Content-Type: application/vcard+xml; charset=UTF-8; 
         . "Content-Disposition: attachment; filename=\"$filename\";\r\n"
         . "\r\n" . $attachment . "\r\n"
         . "\r\n\r\n\r\n"
         . "--$boundary--\r\n\r\n");


     echo "<h1>FAIL!</h1>\n";


I already played around with the CRLF's but no luck. Can anybody tell me 
about the error?

Thx Michael

More information about the Info-cyrus mailing list