integrated attachment_common into the core
authorteepe <teepe@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 13 Nov 2001 23:37:30 +0000 (23:37 +0000)
committerteepe <teepe@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 13 Nov 2001 23:37:30 +0000 (23:37 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1748 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/attachment_common.php [new file with mode: 0644]
functions/mime.php
src/image.php [new file with mode: 0644]
src/load_prefs.php
src/options.php
src/options_display.php
src/read_body.php
src/redirect.php
src/vcard.php [new file with mode: 0644]

diff --git a/functions/attachment_common.php b/functions/attachment_common.php
new file mode 100644 (file)
index 0000000..46eeacd
--- /dev/null
@@ -0,0 +1,185 @@
+<?php
+/**
+ ** attachment_common.php
+ **
+ ** This file provides the handling of often-used attachment types.
+ **
+ ** $Id$
+ **/
+
+  global $FileExtensionToMimeType, $attachment_common_types;
+  $FileExtensionToMimeType = array('bmp'  => 'image/x-bitmap',
+                                   'gif'  => 'image/gif',
+                                   'htm'  => 'text/html',
+                                   'html' => 'text/html',
+                                   'jpg'  => 'image/jpeg',
+                                   'jpeg' => 'image/jpeg',
+                                   'php'  => 'text/plain',
+                                   'png'  => 'image/png',
+                                   'rtf'  => 'text/richtext',
+                                   'txt'  => 'text/plain',
+                                   'vcf'  => 'text/x-vcard');
+
+  // Register browser-supported image types
+  if (isset($attachment_common_types)) {
+     // Don't run this before being logged in. That may happen
+     // when plugins include mime.php
+     foreach ($attachment_common_types as $val => $v) {
+        if ($val == 'image/gif')
+           register_attachment_common('image/gif',       'link_image');
+        elseif (($val == 'image/jpeg' || $val == 'image/pjpeg') and
+                (!isset($jpeg_done))) {
+           $jpeg_done = 1;
+           register_attachment_common('image/jpeg',      'link_image');
+           register_attachment_common('image/pjpeg',     'link_image');
+        }
+        elseif ($val == 'image/png')
+           register_attachment_common('image/png',       'link_image');
+        elseif ($val == 'image/x-xbitmap')
+           register_attachment_common('image/x-xbitmap', 'link_image');
+     }
+     unset($jpeg_done);
+  }
+
+  // Register text-type attachments
+  register_attachment_common('message/rfc822', 'link_text');
+  register_attachment_common('text/plain',     'link_text');
+  register_attachment_common('text/richtext',  'link_text');
+
+  // Register HTML
+  register_attachment_common('text/html',      'link_html');
+
+  // Register vcards
+  register_attachment_common('text/x-vcard',   'link_vcard');
+
+  // Register "unknown" attachments
+  register_attachment_common('application/octet-stream', 'octet_stream');
+
+
+/* Function which optimizes readability of the above code */
+
+function register_attachment_common($type, $func) {
+  global $squirrelmail_plugin_hooks;
+  $squirrelmail_plugin_hooks['attachment ' . $type]['attachment_common'] =
+                      'attachment_common_' . $func;
+}
+
+
+function attachment_common_link_text(&$Args)
+{
+  // If there is a text attachment, we would like to create a 'view' button
+  // that links to the text attachment viewer.
+  //
+  // $Args[1] = the array of actions
+  //
+  // Use our plugin name for adding an action
+  // $Args[1]['attachment_common'] = array for href and text
+  //
+  // $Args[1]['attachment_common']['text'] = What is displayed
+  // $Args[1]['attachment_common']['href'] = Where it links to
+  //
+  // This sets the 'href' of this plugin for a new link.
+  $Args[1]['attachment_common']['href'] = '../src/download.php?startMessage=' .
+     $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
+     '&passed_ent_id=' . $Args[5] . '&override_type0=text&override_type1=plain';
+  
+  // If we got here from a search, we should preserve these variables
+  if ($Args[8] && $Args[9])
+     $Args[1]['attachment_common']['href'] .= '&where=' . 
+     urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
+
+  // The link that we created needs a name.  "view" will be displayed for
+  // all text attachments handled by this plugin.
+  $Args[1]['attachment_common']['text'] = _("view");
+  
+  // Each attachment has a filename on the left, which is a link.
+  // Where that link points to can be changed.  Just in case the link above
+  // for viewing text attachments is not the same as the default link for
+  // this file, we'll change it.
+  //
+  // This is a lot better in the image links, since the defaultLink will just
+  // download the image, but the one that we set it to will format the page
+  // to have an image tag in the center (looking a lot like this text viewer)
+  $Args[6] = $Args[1]['attachment_common']['href'];
+}
+
+
+function attachment_common_link_html(&$Args)
+{
+  $Args[1]['attachment_common']['href'] = '../src/download.php?startMessage=' . 
+     $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
+    '&passed_ent_id=' . $Args[5] . '&override_type0=text&override_type1=html';
+  
+  if ($Args[8] && $Args[9])
+     $Args[1]['attachment_common']['href'] .= '&where=' . 
+     urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
+
+  $Args[1]['attachment_common']['text'] = _("view");
+  
+  $Args[6] = $Args[1]['attachment_common']['href'];
+}
+
+
+function attachment_common_link_image(&$Args)
+{
+  global $attachment_common_show_images, $attachment_common_show_images_list;
+  
+  $info['passed_id'] = $Args[3];
+  $info['mailbox'] = $Args[4];
+  $info['ent_id'] = $Args[5];
+  
+  $attachment_common_show_images_list[] = $info;
+  
+  $Args[1]['attachment_common']['href'] = '../src/image.php?startMessage=' .
+     $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
+     '&passed_ent_id=' . $Args[5];
+  
+  if ($Args[8] && $Args[9])
+     $Args[1]['attachment_common']['href'] .= '&where=' . 
+     urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
+
+  $Args[1]['attachment_common']['text'] = _("view");
+  
+  $Args[6] = $Args[1]['attachment_common']['href'];
+}
+
+
+function attachment_common_link_vcard(&$Args)
+{
+  $Args[1]['attachment_common']['href'] = '../src/vcard.php?startMessage=' .
+     $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
+     '&passed_ent_id=' . $Args[5];
+
+  if (isset($where) && isset($what))
+     $Args[1]['attachment_common']['href'] .= '&where=' . 
+     urlencode($Args[8]) . '&what=' . urlencode($Args[9]);
+
+  $Args[1]['attachment_common']['text'] = _("Business Card");
+
+  $Args[6] = $Args[1]['attachment_common']['href'];
+}
+
+
+function attachment_common_octet_stream(&$Args)
+{
+   global $FileExtensionToMimeType;
+   
+   do_hook('attachment_common-load_mime_types');
+   
+   ereg('\\.([^\\.]+)$', $Args[7], $Regs);
+  
+   $Ext = strtolower($Regs[1]);
+   
+   if ($Ext == '' || ! isset($FileExtensionToMimeType[$Ext]))
+       return;       
+   
+   $Ret = do_hook('attachment ' . $FileExtensionToMimeType[$Ext], 
+       $Args[1], $Args[2], $Args[3], $Args[4], $Args[5], $Args[6], 
+       $Args[7], $Args[8], $Args[9]);
+       
+   foreach ($Ret as $a => $b) {
+       $Args[$a] = $b;
+   }
+}
+
+?>
index cfb9e9d9706255e6b60aa6094b59aa1e01a601e2..74dd9258d1d25ac2c39710b7ded9d5e8a5e6ffc0 100644 (file)
@@ -12,6 +12,7 @@
    define('mime_php', true);
 
    require_once('../functions/imap.php');
+   require_once('../functions/attachment_common.php');
 
    /** Setting up the objects that have the structure for the message **/
 
diff --git a/src/image.php b/src/image.php
new file mode 100644 (file)
index 0000000..8ae17e0
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ ** image.php
+ **
+ ** This file shows an attached image
+ **
+ ** $Id$
+ **/
+
+   require_once('../src/validate.php');
+   require_once('../functions/date.php');
+   require_once('../functions/page_header.php');
+   require_once('../src/load_prefs.php');
+
+
+   displayPageHeader($color, 'None');
+
+   echo '<BR>' . 
+        '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
+        "\n" .
+        '<TR><TD BGCOLOR="' . $color[0] . '">' .
+        '<B><CENTER>' .
+        _("Viewing an image attachment") . " - ";
+   if (isset($where) && isset($what)) {
+      // from a search
+      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+            '&passed_id=' . $passed_id . '&where=' . urlencode($where) . 
+            '&what=' . urlencode($what). '">' . _("View message") . '</a>';
+   } else {   
+      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+           '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
+           '&show_more=0">' . _("View message") . '</a>';
+   }   
+
+   $DownloadLink = '../src/download.php?passed_id=' . $passed_id .
+                   '&mailbox=' . urlencode($mailbox) . 
+                   '&passed_ent_id=' . $passed_ent_id . '&absolute_dl=true';
+
+   echo '</b></td></tr>' . "\n" .
+        '<tr><td align=center><A HREF="' . $DownloadLink . '">' .
+        _("Download this as a file") .
+        '</A></B><BR>&nbsp;' . "\n" .
+        '</TD></TR></TABLE>' . "\n" .
+
+        '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' . "\n" .
+        '<TR><TD BGCOLOR="' . $color[4] . '">' .
+        '<img src="' . $DownloadLink . '">' .
+
+        '</TD></TR></TABLE>' . "\n";
+        '</body></html>' . "\n";
+
+?>
index 377338e6105d38cb5f2bddf083c2004d7806631b..90745ab1ac2f0ab210a7c2c55c0dbd9eca85ef07 100644 (file)
     $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
     $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
 
-    global $collapse_folders, $show_html_default, $show_xmailer_default;
+    global $collapse_folders, $show_html_default, $show_xmailer_default, $attachment_common_show_images;
     $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
 
     /* show_html_default is a int value. */
     $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_ON));
     $show_xmailer_default = intval(getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF ) );
+    $attachment_common_show_images = intval(getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF ) );
 
     global $include_self_reply_all;
     $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
index bcdb43ad9e22d294b1eabc54c66bcbc8acf10b4e..a7b9a08f4aa3dab329cdd6e4517d586005f56735 100644 (file)
@@ -80,6 +80,7 @@
         setPref($data_dir, $username, 'page_selector', $new_page_selector);
         setPref($data_dir, $username, 'page_selector_max', $new_page_selector_max);
         setPref($data_dir, $username, 'show_xmailer_default', $new_show_xmailer_default);
+        setPref($data_dir, $username, 'attachment_common_show_images', $new_attachment_common_show_images);
 
         $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF);
         if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
index 07899f0754f4f053f7e37b4952504648f29db885..edaaf3c4ea123e33cdd26ab7b8dca75d2910de48 100644 (file)
         'refresh' => SMOPT_REFRESH_NONE
     );
 
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
+        'name'    => 'attachment_common_show_images',
+        'caption' => _("Enable display of images with email, below attachment box"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_NONE
+    );
+
     /* Build and output the option groups. */
     $option_groups = createOptionGroups($optgrps, $optvals);
     printOptionGroups($option_groups);
index 8b5ad4662d890ee80cc22d872e3fe63e820b3522..a0e8963627571a2b78e6c6545d8036178857fa5f 100644 (file)
         "   <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>" .
         '</TABLE>' . "\n";
 
+   /* show attached images inline -- if pref'fed so */
+
+   if (($attachment_common_show_images) and
+        is_array($attachment_common_show_images_list)) {
+       foreach ($attachment_common_show_images_list as $img) {
+           echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
+                "  <TR>\n" .
+                "    <TD>\n" .
+                '      <img src="../src/download.php' .
+                    '?passed_id='     . urlencode($img['passed_id']) .
+                    '&mailbox='       . urlencode($img['mailbox']) .
+                    '&passed_ent_id=' . urlencode($img['ent_id']) .
+                    '&absolute_dl=true">' . "\n" .
+                "    </TD>\n" .
+                "  </TR>\n" .
+                "</TABLE>\n";
+       }
+   }
+
    do_hook('read_body_bottom');
    do_hook('html_bottom');
    sqimap_logout($imapConnection);
index 42f23ccf62c430a906a77df5dbda91c86d514594..cb89d5ae633ace6c39e984998c073747f3588c30 100644 (file)
     session_register ('user_is_logged_in');
     session_register ('just_logged_in');
 
+    /* parse the accepted content-types of the client */
+    $attachment_common_types = array();
+    $attachment_common_types_parsed = array();
+    session_register('attachment_common_types');
+    session_register('attachment_common_types_parsed');
+  
+    if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) &&
+        !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']]))
+        attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug);
+    if (isset($HTTP_ACCEPT) &&
+        !isset($attachment_common_types_parsed[$HTTP_ACCEPT]))
+        attachment_common_parse($HTTP_ACCEPT, $debug);
+
+
     /* Complete autodetection of Javascript. */
     checkForPrefs($data_dir, $username);
     $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
 
     /* Send them off to the appropriate page. */
     header("Location: $redirect_url");
+
+
+function attachment_common_parse($str, $debug)
+{
+   global $attachment_common_types, $attachment_common_types_parsed;
+   
+   $attachment_common_types_parsed[$str] = true;
+   $types = explode(', ', $str);
+
+   foreach ($types as $val)
+   {
+      // Ignore the ";q=1.0" stuff
+      if (strpos($val, ';') !== false)
+         $val = substr($val, 0, strpos($val, ';'));
+      
+      if (! isset($attachment_common_types[$val])) {
+        $attachment_common_types[$val] = true;
+      }
+   }
+}
+
 ?>
diff --git a/src/vcard.php b/src/vcard.php
new file mode 100644 (file)
index 0000000..af3695a
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+/**
+ ** vcard.php
+ **
+ ** This file shows an attched vcard
+ **
+ ** $Id$
+ **/
+
+   require_once('../src/validate.php');
+   require_once('../functions/date.php');
+   require_once('../functions/page_header.php');
+   require_once('../functions/mime.php');
+   require_once('../src/load_prefs.php');
+
+   $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+   sqimap_mailbox_select($imapConnection, $mailbox);
+
+
+   displayPageHeader($color, 'None');
+
+   echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
+             'align="center">' . "\n" .
+        '<tr><td bgcolor="' . $color[0] . '">' .
+        '<b><center>' .
+        _("Viewing a Business Card") . " - ";
+   if (isset($where) && isset($what)) {
+      // from a search
+      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+            '&passed_id=' . $passed_id . '&where=' . urlencode($where) . 
+            '&what=' . urlencode($what). '">' . _("View message") . '</a>';
+   } else {   
+      echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
+           '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
+           '&show_more=0">' . _("View message") . '</a>';
+   }   
+   echo '</center></b></td></tr>';
+
+   $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
+
+   $entity_vcard = getEntity($message,$passed_ent_id);
+   
+   $vcard = mime_fetch_body ($imapConnection, $passed_id, $passed_ent_id); 
+   $vcard = decodeBody($vcard, $entity_vcard->header->encoding);
+   $vcard = explode ("\n",$vcard);
+   foreach ($vcard as $l)
+   {
+     $k = substr($l, 0, strpos($l, ':'));
+     $v = substr($l, strpos($l, ':') + 1);
+     $attributes = explode(';', $k);
+     $k = strtolower(array_shift($attributes));
+     foreach ($attributes as $attr)
+     {
+         if ($attr == 'quoted-printable')
+           $v = quoted_printable_decode($v);
+         else
+            $k .= ';' . $attr;
+     }
+    
+     $v = ereg_replace(';', "\n", $v);
+     $vcard_nice[$k] = $v;
+   }
+
+   if ($vcard_nice['version'] == '2.1') 
+   {
+      // get firstname and lastname for sm addressbook
+      $vcard_nice["firstname"] = substr($vcard_nice["n"],
+         strpos($vcard_nice["n"], "\n") + 1, strlen($vcard_nice["n"]));
+      $vcard_nice["lastname"] = substr($vcard_nice["n"], 0, 
+          strpos($vcard_nice["n"], "\n"));
+   }
+   else 
+   {
+      echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] . 
+           ' is not supported.  Some information might not be converted ' .
+          "correctly.</td></tr>\n";
+   }
+   
+   foreach ($vcard_nice as $k => $v)
+   {
+      $v = htmlspecialchars($v);
+      $v = trim($v);
+      $vcard_safe[$k] = trim(nl2br($v));
+   }
+
+   $ShowValues = array(
+     'fn' =>             _("Name"),
+     'title' =>          _("Title"),
+     'email;internet' => _("Email"),
+     'url' =>            _("Web Page"),
+     'org' =>            _("Organization / Department"),
+     'adr' =>            _("Address"),
+     'tel;work' =>       _("Work Phone"),
+     'tel;home' =>       _("Home Phone"),
+     'tel;cell' =>       _("Cellular Phone"),
+     'tel;fax' =>        _("Fax"),
+     'note' =>           _("Note"));
+   echo '<tr><td><br>' .
+        '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
+   
+   if (isset($vcard_safe['email;internet'])) {
+      $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
+          $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
+          '</A>';
+   }
+   if (isset($vcard_safe['url'])) {
+      $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
+          $vcard_safe['url'] . '</A>';
+   }
+   
+   foreach ($ShowValues as $k => $v)
+   {
+       if (isset($vcard_safe[$k]) && $vcard_safe[$k])
+       {
+           echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
+                "</td><tr>\n";
+       }
+   }
+
+   echo '</table>' .
+        '<br>' .
+        '</td></tr></table>' .
+        '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
+          'align="center">' .
+        '<tr>' .
+        '<td bgcolor="' . $color[0] . '">' .
+        '<b><center>' .
+        _("Add to Addressbook") .
+        '</td></tr>' .
+        '<tr><td align=center>' .
+        '<FORM ACTION="../src/addressbook.php" METHOD="POST" NAME=f_add>' .
+        '<table border=0 cellpadding=2 cellspacing=0 align=center>' .
+        '<tr><td align=right><b>Nickname:</b></td>' .
+        '<td><input type=text name="addaddr[nickname]" size=20 value="' .
+        $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] .
+        '"></td></tr>' .
+        '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
+        '<select name="addaddr[label]">';
+
+   if (isset($vcard_nice['url'])) 
+      echo '<option value="' . htmlspecialchars($vcard_nice['url']) . 
+           '">' . _("Web Page") . "</option>\n";
+   if (isset($vcard_nice['adr']))
+      echo '<option value="' . $vcard_nice['adr'] . 
+           '">' . _("Address") . "</option>\n";
+   if (isset($vcard_nice['title']))
+      echo '<option value="' . $vcard_nice['title'] . 
+           '">' . _("Title") . "</option>\n";
+   if (isset($vcard_nice['org']))
+      echo '<option value="' . $vcard_nice['org'] . 
+           '">' . _("Organization / Department") . "</option>\n";
+   if (isset($vcard_nice['title']))
+      echo '<option value="' . $vcard_nice['title'] . 
+           '; ' . $vcard_nice['org'] . 
+           '">' . _("Title & Org. / Dept.") . "</option>\n";
+   if (isset($vcard_nice['tel;work']))
+      echo '<option value="' . $vcard_nice['tel;work'] . 
+           '">' . _("Work Phone") . "</option>\n";
+   if (isset($vcard_nice['tel;home']))
+      echo '<option value="' . $vcard_nice['tel;home'] . 
+           '">' . _("Home Phone") . "</option>\n";
+   if (isset($vcard_nice['tel;cell']))
+      echo '<option value="' . $vcard_nice['tel;cell'] . 
+           '">' . _("Cellular Phone") . "</option>\n";
+   if (isset($vcard_nice['tel;fax']))
+      echo '<option value="' . $vcard_nice['tel;fax'] . 
+           '">' . _("Fax") . "</option>\n";
+   if (isset($vcard_nice['note']))
+      echo '<option value="' . $vcard_nice['note'] . 
+           '">' . _("Note") . "</option>\n";
+
+   echo '</select>' .
+        '</td></tr>' .
+        '<tr><td colspan=2 align=center>' .
+        '<INPUT NAME="addaddr[email]" type=hidden value="' .
+       htmlspecialchars($vcard_nice['email;internet']) . '">' .
+        '<INPUT NAME="addaddr[firstname]" type=hidden value="' .
+       $vcard_safe['firstname'] . '">' .
+        '<INPUT NAME="addaddr[lastname]" type=hidden value="' .
+       $vcard_safe['lastname'] . '">' .
+        '<INPUT TYPE=submit NAME="addaddr[SUBMIT]" ' .
+           'VALUE="Add to Address Book">' .
+        '</td></tr>' .
+        '</table>' .
+        '</FORM>' .
+        '</td></tr>' .
+        '<tr><td align=center>' .
+        '<a href="../src/download.php?absolute_dl=true&passed_id=' .
+        $passed_id . '&mailbox=' . urlencode($mailbox) .
+       '&passed_ent_id=' . $passed_ent_id . '">' .
+        _("Download this as a file") . '</A>' .
+        '</TD></TR></TABLE>' .
+
+        '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
+        '<TR><TD BGCOLOR="' . $color[4] . '">' .
+        '</TD></TR></TABLE>' .
+        '</body></html>';