I got a lot of problems with attachments (multipart emails) and the fix directly below this note.
instead just include it in the optional headers argument as previously suggested:
<?php
$mail = str_replace("\r","",imap_mail_compose($envelope, $body));
imap_mail($_POST["to"],$_POST["subject"],'',$mail);
?>
"Nothing like a fix on a fix".
If you want to copy the message to ie: a sent folder do:
<?php
$envelope["to"] = $_POST["to"]; $envelope["subject"] = $_POST["subject"]; $mail = imap_mail_compose($envelope, $body); imap_append($this->mbox,self::$imapStream."INBOX.Sent",$mail ,"\\Seen");
?>
See imap_append for more info.... Enjoy!