一般的郵件系統中, 與 POP/IMAP 和 SMTP 有關的就是收信/發信的操作. 至於 其他建立目錄, 存為草稿 .. 等等, 都只是一般的信息系統,沒甚麼特別的 .
你可以把草稿,或者郵件都保存在數據庫中, 或者還是作為文件,保存在文件系統中; 這都看具體系統的做法, 與郵件協議無關 ..

解决方案 »

  1.   

    对于建立目录,IMAP里面是提供了函数的,而一个邮件在IMAP里面也是可以标记为一个草稿的,我通过看装在自己电脑上的邮件服务器,那保存的为草稿的东西是以邮件的形式保存在我的信箱里面的。我想也应该可以把这些东西都保存在数据库中,或者以文件方式存储。但我还是想把要保存的东西以邮件的方式存储在我的邮件服务器上面,而不是WEB服务器上。我感觉一般也应该这样存储。
      

  2.   

    我刚写完这两个功能,其实很简单,既然你使用IMAP,那么你肯定有一些class.mime.html.php之类的发送MIME邮件的class。你可以这样实现它:1、存草稿:在你的写邮件功能的PHP文件中加一个变量,用于提交时判断是否保存草稿或保存一份到寄件夹。然后修改你的class.mime.html.php,添加如下函数
    function saveDraft ($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '', $sendsction)
    {
    global $user ,$pass ,$server ,$port ,$port_nr ,$mode ,$mbox ; $to = ($to_name != '')   ? '"'.$to_name.'" <'.$to_addr.'>' : $to_addr;
    $from = ($from_name != '') ? '"'.$from_name.'" <'.$from_addr.'>' : $from_addr; if (is_string($headers)) {
    $headers = explode(CRLF, trim($headers));
    } for ($i=0; $i<count($headers); $i++) {
    if (is_array($headers[$i])) {
    for ($j=0; $j<count($headers[$i]); $j++) {
    if ($headers[$i][$j] != '') {
    $xtra_headers[] = $headers[$i][$j];
    }
    }
    } if ($headers[$i] != '') {
    $xtra_headers[] = $headers[$i];
    }
    }
    if (!isset($xtra_headers)) {
    $xtra_headers = array();
    } /**
            * Encode all headers, Subject, and From
            */
    for ($i=0; $i<count($xtra_headers); $i++) {
    $xtra_headers[$i] = $this->encodeHeader($xtra_headers[$i], $this->build_params['text_charset']);
    } for ($i=0; $i<count($this->headers); $i++) {
    $this->headers[$i] = $this->encodeHeader($this->headers[$i], $this->build_params['text_charset']);
    }

    $to      = $this->encodeHeader($to);
    $subject = $this->encodeHeader($subject);
    $from    = $this->encodeHeader($from); $messages .= 'From: '.$from.CRLF.implode(CRLF, $this->headers).CRLF.implode(CRLF, $xtra_headers);
    $messages .= "To: ".$to."\r\n";
    $messages .= "Subject: ".$subject."\r\n\r\n ";
    $messages .= $this->output; //echo $messages;
    if ($sendsction == "true") { imap_append($mbox,"{".$server."}INBOX.send", $messages ,ST_UID);
    return 1; }elseif($sendsction == ""){ imap_append($mbox,"{".$server."}INBOX.draft", $messages ,ST_UID); $mailbox = imap_open("{".$server.':'.$port_nr.'/'.$port."}INBOX.draft",$user,$pass,$mode) or die("can't connect: ".imap_last_error()); $check = imap_check($mailbox);
    $status = $check->Nmsgs.",1";
    $status = imap_setflag_full($mailbox,$status,"\\draft \\Seen ");
    return 1;
    } }
      

  3.   

    include('class.html.mime.mail.inc.php');

    $mail = new html_mime_mail();

    $mail->html_mime_mail(array("Cc: ".trim(str_replace(";",",",$cc))."\nBcc: ".trim(str_replace(";",",",$bcc))."\nX-Mailer: AS-mail Webmail"));
    //if($sendAsHTML || $settings_signature != "")
    if($sendAsHTML)
    {
    $mail->add_html( stripslashes($body), stripslashes(strip_tags($body)) );
    }
    else
    {
    $mail->add_text($body);
    }

    for($i = 0; $i < count($uploads); $i++)
    {
    $full_mime_type = $uploads[$i]["type"];
    $att_name  = $uploads[$i]["name"];
    $contents  = $uploads[$i]["contents"]; $mail->add_attachment($contents, $att_name, $full_mime_type);
    }

    $mail->build_message(); if ($sendsction == 'true'){
    $mail->saveDraft('', trim($to), '', trim(str_replace(";",",",$from)), stripslashes($subject) ,'',$sendsction);
    } $mail->send('', trim($to), '', trim(str_replace(";",",",$from)), stripslashes($subject) );
      

  4.   

    上述代码的功能是寄信,其中
    if ($sendsction == 'true'){
    $mail->saveDraft('', trim($to), '', trim(str_replace(";",",",$from)), stripslashes($subject) ,'',$sendsction);
    }
    就是将信寄出的同时保存一份到寄件夹
    以下是保存草稿的部分
    if($mail && $to != "" && $Action == "save"){ //保存草稿
    if( count($WARNINGS) <= 0 || $ignore == "true")
    {
    include('class.html.mime.mail.inc.php');
    //这就是我说的MIME发送电子邮件的class

    $mail = new html_mime_mail();

    $mail->html_mime_mail(array("Cc: ".trim(str_replace(";",",",$cc))."\nBcc: ".trim(str_replace(";",",",$bcc))."\nX-Mailer: AS-mail Webmail"));
    //if($sendAsHTML || $settings_signature != "")
    if($sendAsHTML)
    {
    $mail->add_html( stripslashes($body), stripslashes(strip_tags($body)) );
    }
    else
    {
    $mail->add_text($body);
    }

    for($i = 0; $i < count($uploads); $i++)
    {
    $full_mime_type = $uploads[$i]["type"];
    $att_name  = $uploads[$i]["name"];
    $contents  = $uploads[$i]["contents"]; $mail->add_attachment($contents, $att_name, $full_mime_type);
    }

    $mail->build_message();
    $sendsction = "";
    $mail->saveDraft('', trim($to), '', trim(str_replace(";",",",$from)), stripslashes($subject),'','');
    }
      

  5.   

    是有点乱,其实主要就是imap_append()函数的应用,在你用MIME相关的函数生成一封信的原文件后,再用imap_append()写到想保存的信箱中就行了