php imap_append script not working

mistub mistub at gmx.net
Fri Oct 18 15:14:30 CEST 2013


... couldn't handle
>>           . "Content-Transfer-Encoding: 8bit \r\n"

so I encoded the attachment Base64:
> $attachment = chunk_split(base64_encode($attachment8bit));

and it's working now. no idea what the problem was. courier accepts the 
8bit-Transfer-Encoding.

Michael



Am 17.10.2013 22:50, schrieb mistub:
> 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 http://php.net/manual/en/function.imap-append.php )
>
> <?php
> $authhost="{mail.example.org:143/novalidate-cert}INBOX";
>
> $user="foo";
> $pass="bar";
>
> if ($mbox=imap_open( $authhost, $user, $pass))
> {
>       $dmy=date("d-M-Y H:i:s");
>       $file="./example.xml";
>       $filename="example.xml";
>       $ouv=fopen ("$file", "rb");$attachment=fread ($ouv, filesize
> ("$file"));fclose
>       ($ouv);
>
>       $boundary = "------=".md5(uniqid(rand()));
>
>       $msg = ("From: foo at example.org\r\n"
>           . "To: foo at example.org\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/x-vnd.app.contact\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;
> name=\"$filename\"\r\n"
>           . "Content-Disposition: attachment; filename=\"$filename\";\r\n"
>           . "\r\n" . $attachment . "\r\n"
>           . "\r\n\r\n\r\n"
>           . "--$boundary--\r\n\r\n");
>
>       imap_append($mbox,$authhost,$msg);
>
>       imap_close($mbox);
> }
> else
> {
>       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
> ----
> Cyrus Home Page: http://www.cyrusimap.org/
> List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
> To Unsubscribe:
> https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus
>



More information about the users mailing list