mail_reply_forward.inc
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:3k
源码类别:

WEB邮件程序

开发平台:

PHP

  1. <?php
  2. /*
  3. Mail forwarding / replying
  4. --
  5. Forward        - Attatches all of the previous message and attatchments
  6. Reply          - Replies only with from and subject set
  7. Reply Quoted   - Replies with from, subject, and messagebody set
  8. --
  9. */
  10. $mail = new Mail();
  11. $mail->server      = $current_server_settings->server_name;
  12. $mail->user_name   = $current_server_settings->server_username;
  13. $mail->password    = $current_server_settings->server_password;
  14. /* 
  15. The imap true hard code will change as we get other server
  16. type support 
  17. */
  18. $mail->imap        = true;
  19. $ret_vals = $mail->GetFolder( $folder );
  20. if ( $ret_vals[ 0 ] == 1 ) {
  21.    $folder_obj = $ret_vals[ 1 ];
  22. } else {
  23.    $folder_obj = new MailFolder();
  24.    $folder_obj->folder = 'INBOX';
  25. }
  26. list( $ret, $current_header ) = $folder_obj->GetMessageHeader(
  27.    $message_id
  28. );
  29. if ( $form_mode == PIMP_MAIL_REPLY_QUOTED || $form_mode == PIMP_MAIL_REPLY ) {
  30. if ( is_object( $current_header ) ) {
  31.    if ( $current_header->reply_toaddress != '' ) {
  32.       $to_addr = $current_header->reply_toaddress;
  33.    } else {
  34.       $to_addr = $current_header->fromaddress;
  35.    }
  36.    if ( $current_header->ccaddress != '' ) {
  37.       $cc_addr = $current_header->ccaddress;
  38.    }
  39.    if ( $current_header->Subject != '' ) {
  40.       $subject = '';
  41.       if ( ! eregi( '^re: ', $current_header->subject ) ) {
  42.          $subject .= 'Re: ';
  43.       }
  44.       $subject .= $current_header->Subject;
  45.    }
  46. }
  47. }
  48. if ( $form_mode == PIMP_MAIL_FORWARD ) {
  49. if ( is_object( $current_header ) ) {
  50.    if ( $current_header->Subject != '' ) {
  51.       if ( ! eregi( '^fwd: ', $current_header->subject ) ) {
  52.          $subject .= 'Fwd: ';
  53.       }
  54.       $subject .= $current_header->Subject;
  55.    }
  56. }
  57. }
  58. if ( $form_mode == PIMP_MAIL_REPLY_QUOTED || $form_mode == PIMP_MAIL_FORWARD ) {
  59.    /*
  60.    Get the message's content and quote it.
  61.    */
  62.    $current_structure = '';
  63.    $current_structure = $folder_obj->GetMessageStructure( $message_id );
  64.    if ( ! is_object( $current_structure ) ) {
  65.       $current_structure = new BaseObject();
  66.       $current_structure->parts = Array();
  67.    }
  68.    if ( count( $current_structure->parts ) <= 1 ) {
  69.       list( $ret, $mail_mesg ) = $folder_obj->GetMessageBody( $message_id );
  70.    } else {
  71.    for( $i = 0; $i < count( $current_structure->parts ); $i++ ) {
  72.       if ( $struct_item->type == 0 ) {
  73.          /* This should be a piece of a message */
  74.          list( $ret, $bar ) = $folder_obj->GetMessageBodySection(
  75.             $message_id,
  76.             $i + 1
  77.          );
  78.          $mail_mesg .= $bar;
  79.       }
  80.    }
  81.    }
  82.    /* Now let's make it perty */
  83.    $text_util = new TextObject();
  84.    $mail_mesg = $text_util->WrapText( $mail_mesg );
  85.    /* Add the leading > */
  86.    $t_arr = split( "n", $mail_mesg );
  87.    $mail_mesg = '';
  88.    for( $i = 0; $i < count( $t_arr ); $i++ ) {
  89.       $mail_mesg .= '> ' . $t_arr[ $i ] . "n";
  90.    }
  91. }
  92. ?>