- <?php
- /*
- Mail forwarding / replying
- --
- Forward - Attatches all of the previous message and attatchments
- Reply - Replies only with from and subject set
- Reply Quoted - Replies with from, subject, and messagebody set
- --
- */
- $mail = new Mail();
- $mail->server = $current_server_settings->server_name;
- $mail->user_name = $current_server_settings->server_username;
- $mail->password = $current_server_settings->server_password;
- /*
- The imap true hard code will change as we get other server
- type support
- */
- $mail->imap = true;
- $ret_vals = $mail->GetFolder( $folder );
- if ( $ret_vals[ 0 ] == 1 ) {
- $folder_obj = $ret_vals[ 1 ];
- } else {
- $folder_obj = new MailFolder();
- $folder_obj->folder = 'INBOX';
- }
- list( $ret, $current_header ) = $folder_obj->GetMessageHeader(
- $message_id
- );
- if ( $form_mode == PIMP_MAIL_REPLY_QUOTED || $form_mode == PIMP_MAIL_REPLY ) {
- if ( is_object( $current_header ) ) {
- if ( $current_header->reply_toaddress != '' ) {
- $to_addr = $current_header->reply_toaddress;
- } else {
- $to_addr = $current_header->fromaddress;
- }
- if ( $current_header->ccaddress != '' ) {
- $cc_addr = $current_header->ccaddress;
- }
- if ( $current_header->Subject != '' ) {
- $subject = '';
- if ( ! eregi( '^re: ', $current_header->subject ) ) {
- $subject .= 'Re: ';
- }
- $subject .= $current_header->Subject;
- }
- }
- }
- if ( $form_mode == PIMP_MAIL_FORWARD ) {
- if ( is_object( $current_header ) ) {
- if ( $current_header->Subject != '' ) {
- if ( ! eregi( '^fwd: ', $current_header->subject ) ) {
- $subject .= 'Fwd: ';
- }
- $subject .= $current_header->Subject;
- }
- }
- }
- if ( $form_mode == PIMP_MAIL_REPLY_QUOTED || $form_mode == PIMP_MAIL_FORWARD ) {
- /*
- Get the message's content and quote it.
- */
- $current_structure = '';
- $current_structure = $folder_obj->GetMessageStructure( $message_id );
- if ( ! is_object( $current_structure ) ) {
- $current_structure = new BaseObject();
- $current_structure->parts = Array();
- }
- if ( count( $current_structure->parts ) <= 1 ) {
- list( $ret, $mail_mesg ) = $folder_obj->GetMessageBody( $message_id );
- } else {
- for( $i = 0; $i < count( $current_structure->parts ); $i++ ) {
- if ( $struct_item->type == 0 ) {
- /* This should be a piece of a message */
- list( $ret, $bar ) = $folder_obj->GetMessageBodySection(
- $message_id,
- $i + 1
- );
- $mail_mesg .= $bar;
- }
- }
- }
- /* Now let's make it perty */
- $text_util = new TextObject();
- $mail_mesg = $text_util->WrapText( $mail_mesg );
- /* Add the leading > */
- $t_arr = split( "n", $mail_mesg );
- $mail_mesg = '';
- for( $i = 0; $i < count( $t_arr ); $i++ ) {
- $mail_mesg .= '> ' . $t_arr[ $i ] . "n";
- }
- }
- ?>