Hi all,
Doing a small webmail app, and would like copies of outgoing mail to be stored in my sent-mail folder, like with any other mail client. To this end, I have the following bit of code:
if (imap_mail($to, $subject, $body, $additional_headers, $cc, $bcc)) {
$imap_stream = imap_open('{'.$mailhost.'}'.$sentfolder, $username, $password);
imap_append($imap_stream, '{'.$mailhost.'}'.$sentfolder, $message);
echo('<p><center>Message sent.</center></p>');
} else {
$imap_stream = imap_open('{'.$mailhost.'}'.$draftsfolder, $username, $password);
imap_append($imap_stream, '{'.$mailhost.'}'.$draftsfolder, $message);
echo('<p><center><font color="red">Error sending message. Message saved in '.str_replace($prefix, '', $draftsfolder).' folder.</font></center></p>');
}
what happens is that a message is indeed sent, but in fact all the headers (from, to, etc) are left blank, and are actually present in the body of the message. That's not quite right...
Anybody implemented sent-mail appends? How?