Question

I'm making an email client with php and its built in imap functions. I have some issues with the drafts folder. This is how I upload an email after I save it in my own db:

$didAppend = imap_append($this->imap, $mailbox
                , "From: " . $mail->fromContact->EMAIL . "\r\n"
                . "To: you@example.com\r\n"
                . "Subject: " . $mail->subject . "\r\n"
                . "Recent: \r\n"
                . "Draft: X\r\n"
                . "Unseen: X\r\n"
                . "\r\n"
                . $mail->body . "\r\n", "\\Seen"
        );

        if($didAppend) {
            $check = imap_check($this->imap);
            $mail->uid = imap_uid($this->imap, $check->Nmsgs);
            $mail->save();
        }

This way both of my db are in sync untill I change the mail. I couldn't find any imap function that allows me to save changes on the appended mail. Do I have to delete this mail and save a new one every time I make a change to my email?

Was it helpful?

Solution

Yes. Messages in IMAP are immutable. You can change the flags, but that's it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top