php imap_append script not working

mistub mistub at
Thu Oct 17 16:13:39 CEST 2013

Hi all

wanted to send an contact directly to imap via php but got the following 
error (sending without attachment works):

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

For other Cyrus-Imap-Servers the script works. 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: kolab-28hjwer0923409wuer09w34\r\n"
         . "MIME-Version: 1.0\r\n"
         . "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"
         . "X-Kolab-Type: application/\r\n"
         . "X-Kolab-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 Kolab Groupware 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";


Two questions:
Not sure whether appending a contact in this way works as I expected.
What about the php-error?

Thx Michael

More information about the users mailing list