/**
  * Send a multipart email (html and text-plain are supported)
  *
  * @param string $to 
  * @param string $sujet
  * @param string $message_html ( html message version )  
  * @param string $from_name 
  * @param string $from_adr
  * @param string $replay_name   
  * @param string $replay_adr
  * @return bool Email send return (true=send is ok / false=send is ko)
  */
 public function sendEmail($to, $sujet, $message_html, $from_name, $from_adr, $replay_name, $replay_adr)
 {
     $parts = explode("@", $from_adr);
     //filter_var à utiliser pour chaque arguments passé en paramétre.
     if (preg_match("#@(hotmail|live|msn).[a-z]{2,4}\$#", $to)) {
         $passage_ligne = "\n";
     } else {
         $passage_ligne = "\r\n";
     }
     $boundary = "-----=" . md5(rand());
     $message_txt = strip_tags($message_html);
     $message_html = utf8_decode($message_html);
     $headers = "MIME-Version: 1.0\r\n";
     $headers .= "From: " . imap_rfc822_write_address($parts[0], $parts[1], $sujet) . "\r\n";
     $headers .= "Reply-to: \"{$replay_name}\" <{$replay_adr}>" . $passage_ligne;
     $headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
     $message .= "\r\n\r\n--" . $boundary . "\r\n";
     $message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
     $message .= $message_txt;
     $message .= "\r\n\r\n--" . $boundary . "\r\n";
     $message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
     $message .= $message_html;
     $message .= "\r\n\r\n--" . $boundary . "--";
     //return mail($to, $sujet, $message, $headers);
     return mail($to, $sujet, $message, $headers);
 }
Пример #2
0
	function get_info($message_number) {
		$info = array();
		$header	= @imap_header($this->connect, $message_number);
		$info['from'] = @imap_rfc822_write_address($header->from[0]->mailbox, $header->from[0]->host, "");
		$info['to'] = @$this->identifiant;
		$info['subject'] = $this->formate_subject(@$header->subject);
		$info['date'] = $this->formate_date(@$header->date);
		$info['message_id'] = @$header->message_id;
		return $info;
	}
Пример #3
0
 public static function createAddress($mailbox, $host, $personal)
 {
     return imap_rfc822_write_address($mailbox, $host, $personal);
 }
    function emailAddressToHTML($_emailAddress)
    {
        // create some nice formated HTML for senderaddress
        if ($_emailAddress == 'undisclosed-recipients: ;') {
            return $_emailAddress;
        }
        $addressData = imap_rfc822_parse_adrlist($this->bofelamimail->decode_header($_emailAddress), '');
        if (is_array($addressData)) {
            $senderAddress = '';
            while (list($key, $val) = each($addressData)) {
                if (!empty($senderAddress)) {
                    $senderAddress .= ", ";
                }
                if (!empty($val->personal)) {
                    $tempSenderAddress = $val->mailbox . "@" . $val->host;
                    $newSenderAddress = imap_rfc822_write_address($val->mailbox, $val->host, $val->personal);
                    $linkData = array('menuaction' => 'felamimail.uicompose.compose', 'send_to' => base64_encode($newSenderAddress));
                    $link = $GLOBALS['phpgw']->link('/index.php', $linkData);
                    $senderAddress .= sprintf('<a href="%s" title="%s">%s</a>', $link, @htmlentities($newSenderAddress, ENT_QUOTES, $this->displayCharset), @htmlentities($val->personal, ENT_QUOTES, $this->displayCharset));
                    $linkData = array('menuaction' => 'addressbook.uiaddressbook.add_email', 'add_email' => $tempSenderAddress, 'name' => $val->personal, 'referer' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
                    $urlAddToAddressbook = $GLOBALS['phpgw']->link('/index.php', $linkData);
                    $image = $GLOBALS['phpgw']->common->image('felamimail', 'sm_envelope');
                    $senderAddress .= sprintf('<a href="%s">
							<img src="%s" width="10" height="8" border="0" 
							align="absmiddle" alt="%s" 
							title="%s"></a>', $urlAddToAddressbook, $image, lang('add to addressbook'), lang('add to addressbook'));
                } else {
                    $tempSenderAddress = $val->mailbox . "@" . $val->host;
                    $linkData = array('menuaction' => 'felamimail.uicompose.compose', 'send_to' => base64_encode($tempSenderAddress));
                    $link = $GLOBALS['phpgw']->link('/index.php', $linkData);
                    $senderAddress .= sprintf('<a href="%s">%s</a>', $link, @htmlentities($tempSenderAddress, ENT_QUOTES, $this->displayCharset));
                    $linkData = array('menuaction' => 'addressbook.uiaddressbook.add_email', 'add_email' => $tempSenderAddress, 'referer' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
                    $urlAddToAddressbook = $GLOBALS['phpgw']->link('/index.php', $linkData);
                    $image = $GLOBALS['phpgw']->common->image('felamimail', 'sm_envelope');
                    $senderAddress .= sprintf('<a href="%s">
							<img src="%s" width="10" height="8" border="0" 
							align="absmiddle" alt="%s" 
							title="%s"></a>', $urlAddToAddressbook, $image, lang('add to addressbook'), lang('add to addressbook'));
                }
            }
            return $senderAddress;
        }
        // if something goes wrong, just return the original address
        return $_emailAddress;
    }
 function viewMainScreen()
 {
     #printf ("this->uifelamimail->viewMainScreen() start: %s<br>",date("H:i:s",mktime()));
     $bopreferences = CreateObject('felamimail.bopreferences');
     $preferences = $bopreferences->getPreferences();
     $bofilter = CreateObject('felamimail.bofilter');
     $mailPreferences = $bopreferences->getPreferences();
     $urlMailbox = urlencode($this->mailbox);
     $maxMessages = $GLOBALS['phpgw_info']["user"]["preferences"]["common"]["maxmatchs"];
     $this->display_app_header();
     $this->t->set_file(array("body" => 'mainscreen.tpl'));
     $this->t->set_block('body', 'main');
     $this->t->set_block('body', 'status_row_tpl');
     $this->t->set_block('body', 'header_row');
     $this->t->set_block('body', 'error_message');
     $this->t->set_block('body', 'quota_block');
     $this->t->set_block('body', 'subject_same_window');
     $this->t->set_block('body', 'subject_new_window');
     $this->translate();
     $this->t->set_var('oldMailbox', $urlMailbox);
     $this->t->set_var('image_path', PHPGW_IMAGES);
     #printf ("this->uifelamimail->viewMainScreen() Line 272: %s<br>",date("H:i:s",mktime()));
     // ui for the quotas
     if ($quota = $this->bofelamimail->getQuotaRoot()) {
         if ($quota['limit'] == 0) {
             $quotaPercent = 100;
         } else {
             $quotaPercent = round($quota['usage'] * 100 / $quota['limit']);
         }
         $quotaLimit = $this->show_readable_size($quota['limit'] * 1024);
         $quotaUsage = $this->show_readable_size($quota['usage'] * 1024);
         $this->t->set_var('leftWidth', $quotaPercent);
         if ($quotaPercent > 90) {
             $this->t->set_var('quotaBG', 'red');
         } elseif ($quotaPercent > 80) {
             $this->t->set_var('quotaBG', 'yellow');
         } else {
             $this->t->set_var('quotaBG', '#66ff66');
         }
         if ($quotaPercent > 50) {
             $this->t->set_var('quotaUsage_right', '');
             $this->t->set_var('quotaUsage_left', $quotaUsage . '/' . $quotaLimit);
         } else {
             $this->t->set_var('quotaUsage_left', '');
             $this->t->set_var('quotaUsage_right', $quotaUsage . '/' . $quotaLimit);
         }
         $this->t->parse('quota_display', 'quota_block', True);
     } else {
         $this->t->set_var('quota_display', '&nbsp;');
     }
     // set the images
     $listOfImages = array('read_small', 'unread_small', 'unread_flagged_small', 'read_flagged_small', 'trash', 'sm_envelope', 'write_mail', 'manage_filter', 'msg_icon_sm', 'mail_find', 'new');
     foreach ($listOfImages as $image) {
         $this->t->set_var($image, $GLOBALS['phpgw']->common->image('felamimail', $image));
     }
     // refresh settings
     $refreshTime = $preferences['refreshTime'];
     if ($refreshTime > 0) {
         $this->t->set_var('refreshTime', sprintf("aktiv = window.setTimeout( \"refresh()\", %s );", $refreshTime * 60 * 1000));
     } else {
         $this->t->set_var('refreshTime', '');
     }
     // set the url to open when refreshing
     $linkData = array('menuaction' => 'felamimail.uifelamimail.viewMainScreen');
     $this->t->set_var('refresh_url', $GLOBALS['phpgw']->link('/index.php', $linkData));
     // define the sort defaults
     $dateSort = '0';
     $dateCSS = 'text_small';
     $fromSort = '3';
     $fromCSS = 'text_small';
     $subjectSort = '5';
     $subjectCSS = 'text_small';
     $sizeSort = '6';
     $sizeCSS = 'text_small';
     // and no overwrite the defaults
     switch ($this->sort) {
         // sort by date newest first
         case '0':
             $dateSort = '1';
             $dateCSS = 'text_small_bold';
             break;
             // sort by date oldest first
         // sort by date oldest first
         case '1':
             $dateSort = '0';
             $dateCSS = 'text_small_bold';
             break;
             // sort by from z->a
         // sort by from z->a
         case '2':
             $fromSort = '3';
             $fromCSS = 'text_small_bold';
             break;
             // sort by from a->z
         // sort by from a->z
         case '3':
             $fromSort = '2';
             $fromCSS = 'text_small_bold';
             break;
             // sort by subject z->a
         // sort by subject z->a
         case '4':
             $subjectSort = '5';
             $subjectCSS = 'text_small_bold';
             break;
             // sort by subject a->z
         // sort by subject a->z
         case '5':
             $subjectSort = '4';
             $subjectCSS = 'text_small_bold';
             break;
             // sort by size z->a
         // sort by size z->a
         case '6':
             $sizeSort = '7';
             $sizeCSS = 'text_small_bold';
             break;
             // sort by subject a->z
         // sort by subject a->z
         case '7':
             $sizeSort = '6';
             $sizeCSS = 'text_small_bold';
             break;
     }
     // sort by date
     $linkData = array('menuaction' => 'felamimail.uifelamimail.changeSorting', 'startMessage' => 1, 'sort' => $dateSort);
     $this->t->set_var('url_sort_date', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $this->t->set_var('css_class_date', $dateCSS);
     // sort by from
     $linkData = array('menuaction' => 'felamimail.uifelamimail.changeSorting', 'startMessage' => 1, 'sort' => $fromSort);
     $this->t->set_var('url_sort_from', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $this->t->set_var('css_class_from', $fromCSS);
     // sort by subject
     $linkData = array('menuaction' => 'felamimail.uifelamimail.changeSorting', 'startMessage' => 1, 'sort' => $subjectSort);
     $this->t->set_var('url_sort_subject', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $this->t->set_var('css_class_subject', $subjectCSS);
     // sort by size
     $linkData = array('menuaction' => 'felamimail.uifelamimail.changeSorting', 'startMessage' => 1, 'sort' => $sizeSort);
     $this->t->set_var('url_sort_size', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $this->t->set_var('css_class_size', $sizeCSS);
     // create the filter ui
     $filterList = $bofilter->getFilterList();
     $activeFilter = $bofilter->getActiveFilter();
     // -1 == no filter selected
     if ($activeFilter == -1) {
         $filterUI .= "<option value=\"-1\" selected>" . lang('no filter') . "</option>";
     } else {
         $filterUI .= "<option value=\"-1\">" . lang('no filter') . "</option>";
     }
     while (list($key, $value) = @each($filterList)) {
         $selected = "";
         if ($activeFilter == $key) {
             $selected = "selected";
         }
         $filterUI .= "<option value=" . $key . " {$selected}>" . $value['filterName'] . "</option>";
     }
     $this->t->set_var('filter_options', $filterUI);
     // 0 == quicksearch
     if ($activeFilter == '0') {
         $this->t->set_var('quicksearch', $filterList[0]['subject']);
     }
     if ($this->connectionStatus != 'True') {
         $this->t->set_var('message', $this->connectionStatus);
         $this->t->parse('header_rows', 'error_message', True);
     } else {
         $folders = $this->bofelamimail->getFolderList('true');
         $headers = $this->bofelamimail->getHeaders($this->startMessage, $maxMessages, $this->sort);
         $headerCount = count($headers['header']);
         if ($mailPreferences['sent_folder'] == $this->mailbox) {
             $this->t->set_var('lang_from', lang("to"));
         } else {
             $this->t->set_var('lang_from', lang("from"));
         }
         $msg_icon_sm = $GLOBALS['phpgw']->common->image('felamimail', 'msg_icon_sm');
         for ($i = 0; $i < $headerCount; $i++) {
             // create the listing of subjects
             $maxSubjectLength = 60;
             $maxAddressLength = 20;
             $maxSubjectLengthBold = 50;
             $maxAddressLengthBold = 14;
             $flags = "";
             if (!empty($headers['header'][$i]['recent'])) {
                 $flags .= "R";
             }
             if (!empty($headers['header'][$i]['flagged'])) {
                 $flags .= "F";
             }
             if (!empty($headers['header'][$i]['answered'])) {
                 $flags .= "A";
             }
             if (!empty($headers['header'][$i]['deleted'])) {
                 $flags .= "D";
             }
             if (!empty($headers['header'][$i]['seen'])) {
                 $flags .= "S";
             }
             switch ($flags) {
                 case "":
                     $this->t->set_var('imageName', 'unread_small.png');
                     $this->t->set_var('row_text', lang('new'));
                     $maxAddressLength = $maxAddressLengthBold;
                     $maxSubjectLength = $maxSubjectLengthBold;
                     break;
                 case "D":
                 case "DS":
                 case "ADS":
                     $this->t->set_var('imageName', 'unread_small.png');
                     $this->t->set_var('row_text', lang('deleted'));
                     break;
                 case "F":
                     $this->t->set_var('imageName', 'unread_flagged_small.png');
                     $this->t->set_var('row_text', lang('new'));
                     $maxAddressLength = $maxAddressLengthBold;
                     break;
                 case "FS":
                     $this->t->set_var('imageName', 'read_flagged_small.png');
                     $this->t->set_var('row_text', lang('replied'));
                     break;
                 case "FAS":
                     $this->t->set_var('imageName', 'read_answered_flagged_small.png');
                     $this->t->set_var('row_text', lang('replied'));
                     break;
                 case "S":
                 case "RS":
                     $this->t->set_var('imageName', 'read_small.png');
                     $this->t->set_var('row_text', lang('read'));
                     break;
                 case "R":
                     $this->t->set_var('imageName', 'recent_small.gif');
                     $this->t->set_var('row_text', '*' . lang('recent') . '*');
                     $maxAddressLength = $maxAddressLengthBold;
                     break;
                 case "RAS":
                 case "AS":
                     $this->t->set_var('imageName', 'read_answered_small.png');
                     $this->t->set_var('row_text', lang('replied'));
                     #$maxAddressLength = $maxAddressLengthBold;
                     break;
                 default:
                     $this->t->set_var('row_text', $flags);
                     break;
             }
             #_debug_array($GLOBALS[phpgw_info]);
             if (!empty($headers['header'][$i]['subject'])) {
                 // make the subject shorter if it is to long
                 $fullSubject = $headers['header'][$i]['subject'];
                 #if(strlen($headers['header'][$i]['subject']) > $maxSubjectLength)
                 #{
                 #	$headers['header'][$i]['subject'] = substr($headers['header'][$i]['subject'],0,$maxSubjectLength)."...";
                 #}
                 $headers['header'][$i]['subject'] = @htmlspecialchars($headers['header'][$i]['subject'], ENT_QUOTES, $this->displayCharset);
                 if ($headers['header'][$i]['attachments'] == "true") {
                     $image = '<img src="' . $GLOBALS['phpgw']->common->image('felamimail', 'attach') . '" border="0">';
                     //modified NDEE 29-12-03 for
                     //separate attachment icon
                     //$headers['header'][$i]['subject'] = "$image&nbsp;".$headers['header'][$i]['subject'];
                     $headers['header'][$i]['attachment'] = $image;
                 }
                 $this->t->set_var('header_subject', $headers['header'][$i]['subject']);
                 // added
                 $this->t->set_var('attachments', $headers['header'][$i]['attachment']);
                 $this->t->set_var('full_subject', @htmlspecialchars($fullSubject, ENT_QUOTES, $this->displayCharset));
             } else {
                 $this->t->set_var('header_subject', @htmlentities("(" . lang('no subject') . ")", ENT_QUOTES, $this->displayCharset));
             }
             if ($mailPreferences['sent_folder'] == $this->mailbox) {
                 if (!empty($headers['header'][$i]['to_name'])) {
                     $sender_name = $headers['header'][$i]['to_name'];
                     $full_address = $headers['header'][$i]['to_name'] . " <" . $headers['header'][$i]['to_address'] . ">";
                 } else {
                     $sender_name = $headers['header'][$i]['to_address'];
                     $full_address = $headers['header'][$i]['to_address'];
                 }
                 #$this->t->set_var('lang_from',lang("to"));
             } else {
                 if (!empty($headers['header'][$i]['sender_name'])) {
                     $sender_name = $headers['header'][$i]['sender_name'];
                     $full_address = @htmlentities($headers['header'][$i]['sender_name'] . " <" . $headers['header'][$i]['sender_address'] . ">", ENT_QUOTES, $this->displayCharset);
                 } else {
                     $sender_name = $headers['header'][$i]['sender_address'];
                     $full_address = $headers['header'][$i]['sender_address'];
                 }
                 #$this->t->set_var('lang_from',lang("from"));
             }
             #if(strlen($sender_name) > $maxAddressLength)
             #{
             #	$sender_name = substr($sender_name,0,$maxAddressLength)."...";
             #}
             $this->t->set_var('sender_name', @htmlentities($sender_name, ENT_QUOTES, $this->displayCharset));
             $this->t->set_var('full_address', $full_address);
             if ($GLOBALS['HTTP_GET_VARS']["select_all"] == "select_all") {
                 $this->t->set_var('row_selected', "checked");
             }
             $this->t->set_var('message_counter', $i);
             $this->t->set_var('message_uid', $headers['header'][$i]['uid']);
             // HINT: date style should be set according to preferences!
             $this->t->set_var('date', $headers['header'][$i]['date']);
             $this->t->set_var('size', $this->show_readable_size($headers['header'][$i]['size']));
             $linkData = array('menuaction' => 'felamimail.uidisplay.display', 'showHeader' => 'false', 'uid' => $headers['header'][$i]['uid']);
             if ($preferences['messageNewWindow']) {
                 $this->t->set_var('url_read_message', "javascript:displayMessage('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "');");
             } else {
                 $this->t->set_var('url_read_message', $GLOBALS['phpgw']->link('/index.php', $linkData));
             }
             if (!empty($headers['header'][$i]['sender_name'])) {
                 list($mailbox, $host) = explode('@', $headers['header'][$i]['sender_address']);
                 $senderAddress = imap_rfc822_write_address($mailbox, $host, $headers['header'][$i]['sender_name']);
                 $linkData = array('menuaction' => 'felamimail.uicompose.compose', 'send_to' => base64_encode($senderAddress));
             } else {
                 $linkData = array('menuaction' => 'felamimail.uicompose.compose', 'send_to' => base64_encode($headers['header'][$i]['sender_address']));
             }
             if ($preferences['messageNewWindow']) {
                 $this->t->set_var('url_compose', "javascript:displayMessage('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "');");
             } else {
                 $this->t->set_var('url_compose', $GLOBALS['phpgw']->link('/index.php', $linkData));
             }
             $linkData = array('menuaction' => 'addressbook.uiaddressbook.add_email', 'add_email' => urlencode($headers['header'][$i]['sender_address']), 'name' => urlencode($headers['header'][$i]['sender_name']), 'referer' => urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']));
             $this->t->set_var('url_add_to_addressbook', $GLOBALS['phpgw']->link('/index.php', $linkData));
             $this->t->set_var('msg_icon_sm', $msg_icon_sm);
             $this->t->set_var('phpgw_images', PHPGW_IMAGES);
             $this->t->set_var('row_css_class', 'header_row_' . $flags);
             $this->t->parse('header_rows', 'header_row', True);
         }
         $firstMessage = $headers['info']['first'];
         $lastMessage = $headers['info']['last'];
         $totalMessage = $headers['info']['total'];
         $langTotal = lang("total");
     }
     $this->t->set_var('maxMessages', $i);
     if ($GLOBALS['HTTP_GET_VARS']["select_all"] == "select_all") {
         $this->t->set_var('checkedCounter', $i);
     } else {
         $this->t->set_var('checkedCounter', '0');
     }
     // set the select all/nothing link
     if ($GLOBALS['HTTP_GET_VARS']["select_all"] == "select_all") {
         // link to unselect all messages
         $linkData = array('menuaction' => 'felamimail.uifelamimail.viewMainScreen');
         $selectLink = sprintf("<a class=\"body_link\" href=\"%s\">%s</a>", $GLOBALS['phpgw']->link('/index.php', $linkData), lang("Unselect All"));
         $this->t->set_var('change_folder_checked', '');
         $this->t->set_var('move_message_checked', 'checked');
     } else {
         // link to select all messages
         $linkData = array('select_all' => 'select_all', 'menuaction' => 'felamimail.uifelamimail.viewMainScreen');
         $selectLink = sprintf("<a class=\"body_link\" href=\"%s\">%s</a>", $GLOBALS['phpgw']->link('/index.php', $linkData), lang("Select all"));
         $this->t->set_var('change_folder_checked', 'checked');
         $this->t->set_var('move_message_checked', '');
     }
     $this->t->set_var('select_all_link', $selectLink);
     // create the links for the delete options
     // "delete all" in the trash folder
     // "compress folder" in normal folders
     if ($mailPreferences['trash_folder'] == $this->mailbox && $mailPreferences['deleteOptions'] == "move_to_trash") {
         $linkData = array('menuaction' => 'felamimail.uifelamimail.compressFolder');
         $trashLink = sprintf("<a class=\"body_link\" href=\"%s\">%s</a>", $GLOBALS['phpgw']->link('/index.php', $linkData), lang("delete all"));
         $this->t->set_var('trash_link', $trashLink);
     } elseif ($mailPreferences['deleteOptions'] == "mark_as_deleted") {
         $linkData = array('menuaction' => 'felamimail.uifelamimail.compressFolder');
         $trashLink = sprintf("<a class=\"body_link\" href=\"%s\">%s</a>", $GLOBALS['phpgw']->link('/index.php', $linkData), lang("compress folder"));
         $this->t->set_var('trash_link', $trashLink);
     }
     $this->t->set_var('message', lang("Viewing messages") . " <b>{$firstMessage}</b> - <b>{$lastMessage}</b> ({$totalMessage} {$langTotal})");
     if ($firstMessage > 1) {
         $linkData = array('menuaction' => 'felamimail.uifelamimail.viewMainScreen', 'startMessage' => $this->startMessage - $maxMessages);
         $link = $GLOBALS['phpgw']->link('/index.php', $linkData);
         $this->t->set_var('link_previous', "<a class=\"body_link\" href=\"{$link}\">" . lang("previous") . "</a>");
     } else {
         $this->t->set_var('link_previous', lang("previous"));
     }
     if ($totalMessage > $lastMessage) {
         $linkData = array('menuaction' => 'felamimail.uifelamimail.viewMainScreen', 'startMessage' => $this->startMessage + $maxMessages);
         $link = $GLOBALS['phpgw']->link('/index.php', $linkData);
         $this->t->set_var('link_next', "<a class=\"body_link\" href=\"{$link}\">" . lang("next") . "</a>");
     } else {
         $this->t->set_var('link_next', lang("next"));
     }
     $this->t->parse('status_row', 'status_row_tpl', True);
     @reset($folders);
     // Start of the new folder tree system
     // 29-12-2003 NDEE
     // ToDo
     // check how many mails in folder
     // different style of parsing folders into file
     // open to active folder on reload
     $folder_tree_new = $this->createHTMLFolder($folders, $this->mailbox, lang('IMAP Server'), $mailPreferences['username'] . '@' . $mailPreferences['imapServerAddress']);
     $this->t->set_var('current_mailbox', $current_mailbox);
     $this->t->set_var('folder_tree', $folder_tree_new);
     #$this->t->set_var('foldertree_image_path',PHPGW_IMAGES_DIR.'/foldertree/');
     $this->t->set_var('options_folder', $options_folder);
     $linkData = array('menuaction' => 'felamimail.uicompose.compose');
     if ($preferences['messageNewWindow']) {
         $this->t->set_var('url_compose_empty', "javascript:displayMessage('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "');");
     } else {
         $this->t->set_var('url_compose_empty', $GLOBALS['phpgw']->link('/index.php', $linkData));
     }
     $linkData = array('menuaction' => 'felamimail.uifilter.mainScreen');
     $this->t->set_var('url_filter', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $linkData = array('menuaction' => 'felamimail.uifelamimail.handleButtons');
     $this->t->set_var('url_change_folder', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $linkData = array('menuaction' => 'felamimail.uifelamimail.changeFilter');
     $this->t->set_var('url_search_settings', $GLOBALS['phpgw']->link('/index.php', $linkData));
     $this->t->set_var('lang_mark_messages_as', lang('mark messages as'));
     $this->t->set_var('lang_delete', lang('delete'));
     $this->t->parse("out", "main");
     print $this->t->get('out', 'main');
     if ($this->connectionStatus == 'True') {
         $this->bofelamimail->closeConnection();
     }
     $GLOBALS['phpgw']->common->phpgw_footer();
 }
Пример #6
0
 /**
  * This function will create an Email Address to RFC822 specifications. 
  *
  * @param $username - name before the @ sign in an email  address. 
  * @param $host - address after the @ sign in an email address.
  * @param $name - name of the person
  *
  * @return Email Address in the following format:
  *  FirstName LastName <*****@*****.**>
  */
 public function createAddress($username, $host, $name)
 {
     $adr = imap_rfc822_write_address($username, $host, $name);
     return $adr;
 }
Пример #7
0
 /**
  * Method to create an RFC822 formatted email address eg Paul Scott <*****@*****.**>
  *
  * @access public
  * @param string $user - pscott
  * @param string $domain - uwc.ac.za
  * @param string $name - Paul Scott
  * @return email address
  */
 public function setAddress($user, $domain, $name)
 {
     return imap_rfc822_write_address($user, $domain, $name);
 }
 function getMessageEnvelope($_uid, $_partID = '')
 {
     if ($_partID == '') {
         if (PEAR::isError($envelope = $this->icServer->getEnvelope('', $_uid, true))) {
             return false;
         }
         return $envelope[0];
     } else {
         if (PEAR::isError($headers = $this->icServer->getParsedHeaders($_uid, true, $_partID, true))) {
             return false;
         }
         #_debug_array($headers);
         $newData = array('DATE' => $headers['DATE'], 'SUBJECT' => $headers['SUBJECT'], 'MESSAGE_ID' => $headers['MESSAGE-ID']);
         $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY_TO');
         foreach ($recepientList as $recepientType) {
             if (isset($headers[$recepientType])) {
                 $addresses = imap_rfc822_parse_adrlist($headers[$recepientType], '');
                 foreach ($addresses as $singleAddress) {
                     $addressData = array('PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', 'MAILBOX_NAME' => $singleAddress->mailbox ? $singleAddress->mailbox : 'NIL', 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox . '@' . $singleAddress->host : $singleAddress->mailbox);
                     if ($addressData['PERSONAL_NAME'] != 'NIL') {
                         $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal);
                     } else {
                         $addressData['RFC822_EMAIL'] = 'NIL';
                     }
                     $newData[$recepientType][] = $addressData;
                 }
             } else {
                 if ($recepientType == 'SENDER' || $recepientType == 'REPLY_TO') {
                     $newData[$recepientType] = $newData['FROM'];
                 } else {
                     $newData[$recepientType] = array();
                 }
             }
         }
         #_debug_array($newData);
         return $newData;
     }
 }
 function messageTable($_headers, $_folderType, $_folderName, $_readInNewWindow, $_rowStyle = 'felamimail')
 {
     $this->t =& CreateObject('phpgwapi.Template', PHPGW_APP_TPL);
     $this->t->set_file(array("body" => 'mainscreen.tpl'));
     $this->t->set_block('body', 'header_row_felamimail');
     $this->t->set_block('body', 'header_row_outlook');
     $this->t->set_block('body', 'message_table');
     $timestamp7DaysAgo = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 7, date("Y"));
     $timestampNow = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
     $dateToday = date("Y-m-d");
     $i = 0;
     foreach ((array) $_headers['header'] as $header) {
         //_debug_array($header);
         #if($i<10) {$i++;continue;}
         #if($i>20) {continue;} $i++;
         // create the listing of subjects
         $maxSubjectLength = 60;
         $maxAddressLength = 20;
         $maxSubjectLengthBold = 50;
         $maxAddressLengthBold = 14;
         $flags = "";
         if (!empty($header['recent'])) {
             $flags .= "R";
         }
         if (!empty($header['flagged'])) {
             $flags .= "F";
         }
         if (!empty($header['answered'])) {
             $flags .= "A";
         }
         if (!empty($header['forwarded'])) {
             $flags .= "W";
         }
         if (!empty($header['deleted'])) {
             $flags .= "D";
         }
         if (!empty($header['seen'])) {
             $flags .= "S";
         }
         $this->t->set_var('row_text', '');
         // the status icon
         if ($header['deleted']) {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgdel'));
         } elseif ($header['recent']) {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgnew'));
         } elseif ($header['forwarded']) {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgforwarded'));
         } elseif ($header['answered']) {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgreplied'));
         } elseif ($header['seen']) {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgread'));
         } else {
             $this->t->set_var('image_url', html::image('felamimail', 'kmmsgunseen'));
         }
         // the css for this row
         if ($header['deleted']) {
             $this->t->set_var('row_css_class', 'header_row_D');
         } elseif ($header['recent'] && !$header['seen']) {
             $this->t->set_var('row_css_class', 'header_row_R');
         } elseif ($header['flagged']) {
             if ($header['seen']) {
                 $this->t->set_var('row_css_class', 'header_row_FS');
             } else {
                 $this->t->set_var('row_css_class', 'header_row_F');
             }
         } elseif ($header['seen']) {
             $this->t->set_var('row_css_class', 'header_row_S');
         } else {
             $this->t->set_var('row_css_class', 'header_row_');
         }
         // filter out undisplayable characters
         $search = array('[\\016]', '[\\017]', '[\\020]', '[\\021]', '[\\022]', '[\\023]', '[\\024]', '[\\025]', '[\\026]', '[\\027]', '[\\030]', '[\\031]', '[\\032]', '[\\033]', '[\\034]', '[\\035]', '[\\036]', '[\\037]');
         $replace = '';
         $header['subject'] = preg_replace($search, $replace, $header['subject']);
         $header['subject'] = @htmlspecialchars($header['subject'], ENT_QUOTES, $this->displayCharset);
         // curly brackets get messed up by the template!
         $header['subject'] = str_replace(array('{', '}'), array('&#x7B;', '&#x7D;'), $header['subject']);
         if (!empty($header['subject'])) {
             // make the subject shorter if it is to long
             $fullSubject = $header['subject'];
             #if(strlen($header['subject']) > $maxSubjectLength)
             #{
             #	$header['subject'] = substr($header['subject'],0,$maxSubjectLength)."...";
             #}
             $this->t->set_var('header_subject', $header['subject']);
             #$this->t->set_var('attachments', $header['attachment']);
             $this->t->set_var('full_subject', $fullSubject);
         } else {
             $this->t->set_var('header_subject', @htmlspecialchars('(' . lang('no subject') . ')', ENT_QUOTES, $this->displayCharset));
         }
         #_debug_array($header);
         if ($header['mimetype'] == 'multipart/mixed' || $header['mimetype'] == 'multipart/related' || substr($header['mimetype'], 0, 11) == 'application' || substr($header['mimetype'], 0, 5) == 'audio') {
             $image = html::image('felamimail', 'attach');
             $this->t->set_var('attachment_image', $image);
         } else {
             $this->t->set_var('attachment_image', '&nbsp;');
         }
         // show priority flag
         if ($header['priority'] < 3) {
             $image = html::image('felamimail', 'prio_high');
         } elseif ($header['priority'] > 3) {
             $image = html::image('felamimail', 'prio_low');
         } else {
             $image = '';
         }
         $this->t->set_var('prio_image', $image);
         if ($_folderType > 0) {
             // sent or drafts or template folder
             if (!empty($header['to_name'])) {
                 $sender_name = $header['to_name'];
                 $full_address = $header['to_name'] . ' <' . $header['to_address'] . '>';
             } else {
                 $sender_name = $header['to_address'];
                 $full_address = $header['to_address'];
             }
         } else {
             if (!empty($header['sender_name'])) {
                 $sender_name = $header['sender_name'];
                 $full_address = $header['sender_name'] . ' <' . $header['sender_address'] . '>';
             } else {
                 $sender_name = $header['sender_address'];
                 $full_address = $header['sender_address'];
             }
         }
         $this->t->set_var('sender_name', @htmlspecialchars($sender_name, ENT_QUOTES, $this->charset));
         $this->t->set_var('full_address', @htmlspecialchars($full_address, ENT_QUOTES, $this->charset));
         $this->t->set_var('message_counter', $i);
         $this->t->set_var('message_uid', $header['uid']);
         if ($dateToday == date('Y-m-d', $header['date'])) {
             $this->t->set_var('date', $GLOBALS['phpgw']->common->show_date($header['date'], 'H:i:s'));
         } else {
             $this->t->set_var('date', $GLOBALS['phpgw']->common->show_date($header['date'], $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']));
         }
         $this->t->set_var('datetime', $GLOBALS['phpgw']->common->show_date($header['date']));
         $this->t->set_var('size', $this->show_readable_size($header['size']));
         if ($_folderType == 2 || $_folderType == 3) {
             $linkData = array('menuaction' => 'felamimail.uicompose.composeFromDraft', 'icServer' => 0, 'folder' => base64_encode($_folderName), 'uid' => $header['uid'], 'id' => $header['id']);
             $this->t->set_var('url_read_message', $GLOBALS['phpgw']->link('/index.php', $linkData));
             $windowName = 'composeFromDraft_' . $header['uid'];
             $this->t->set_var('read_message_windowName', $windowName);
         } else {
             #	_debug_array($header);
             $linkData = array('menuaction' => 'felamimail.uidisplay.display', 'showHeader' => 'false', 'mailbox' => base64_encode($_folderName), 'uid' => $header['uid'], 'id' => $header['id']);
             $this->t->set_var('url_read_message', $GLOBALS['phpgw']->link('/index.php', $linkData));
             $windowName = $_readInNewWindow == 1 ? 'displayMessage' : 'displayMessage_' . $header['uid'];
             $this->t->set_var('read_message_windowName', $windowName);
         }
         if ($_folderType > 0) {
             // sent or draft or template folder
             if (!empty($header['to_name'])) {
                 list($mailbox, $host) = explode('@', $header['to_address']);
                 $senderAddress = imap_rfc822_write_address($mailbox, $host, $header['to_name']);
             } else {
                 $senderAddress = $header['to_address'];
             }
         } else {
             if (!empty($header['sender_name'])) {
                 list($mailbox, $host) = explode('@', $header['sender_address']);
                 $senderAddress = imap_rfc822_write_address($mailbox, $host, $header['sender_name']);
             } else {
                 $senderAddress = $header['sender_address'];
             }
         }
         $linkData = array('menuaction' => 'felamimail.uicompose.compose', 'send_to' => base64_encode($senderAddress));
         $windowName = 'compose' . $header['uid'];
         $this->t->set_var('url_compose', "egw_openWindowCentered('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "','{$windowName}',700,egw_getWindowOuterHeight());");
         $linkData = array('menuaction' => 'addressbook.addressbook_ui.edit', 'presets[email]' => urlencode($header['sender_address']), 'presets[n_given]' => urlencode($header['sender_name']), 'referer' => urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']));
         //TODO: url_add_to_addressbook isn't in any of the templates.
         //If you want to use it, you need to adopt syntax to the new addressbook (popup)
         $this->t->set_var('url_add_to_addressbook', $GLOBALS['phpgw']->link('/index.php', $linkData));
         $this->t->set_var('msg_icon_sm', $msg_icon_sm);
         $this->t->set_var('phpgw_images', PHPGW_IMAGES);
         switch ($_rowStyle) {
             case 'outlook':
                 $this->t->parse('message_rows', 'header_row_outlook', True);
                 break;
             default:
                 $this->t->parse('message_rows', 'header_row_felamimail', True);
                 break;
         }
     }
     $this->t->parse("out", "message_table");
     return $this->t->get('out', 'message_table');
 }