Browse Source

added auto-lookup functionality -- aliases can now be typed in address bars
in the compose form.

Luke Ehresman 24 years ago
parent
commit
cfb9f5b1a0
2 changed files with 28 additions and 6 deletions
  1. 2 0
      ChangeLog
  2. 26 6
      functions/smtp.php

+ 2 - 0
ChangeLog

@@ -1,5 +1,7 @@
 Version 1.1.0 -- DEVELOPMENT
 ----------------------------
+- If aliases are typed in To, Cc, or Bcc, they are automatically lookedup in
+  in the addressbook and converted to the associated addresses.
 - Added collapseable folder listing (an option that can be turned on)
 - Added alternating row colors to improve interface
 - Added Croatian translation by Albert Novak <anovak@pu.carnet.hr>

+ 26 - 6
functions/smtp.php

@@ -8,6 +8,8 @@
     **/
 
    $smtp_php = true;
+   if (!isset($addressbook_php))
+      include('../functions/addressbook.php');
 
    // This should most probably go to some initialization...
    if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
@@ -31,6 +33,24 @@
          return false;
    }
 
+   // looks up aliases in the addressbook and expands them to
+   // the full address.
+   function expandAddrs ($array) {
+      $abook = addressbook_init();
+      for ($i=0; $i < count($array); $i++) {
+         $result = $abook->lookup($array[$i]);
+         $ret = "";
+         if (isset($result['email'])) {
+            if (isset($result['name'])) {
+               $ret = '"'.$result['name'].'" ';
+            }
+            $ret .= '<'.$result['email'].'>';
+            $array[$i] = $ret;
+         }
+      }
+      return $array;
+   }
+
    // Attach the files that are due to be attached
    function attachFiles ($fp) {
       global $attachments, $attachment_dir;
@@ -131,9 +151,9 @@
       static $header, $headerlength;
 
       if ($header == '') {
-         $to = parseAddrs($t);
-         $cc = parseAddrs($c);
-         $bcc = parseAddrs($b);
+         $to = expandAddrs(parseAddrs($t));
+         $cc = expandAddrs(parseAddrs($c));
+         $bcc = expandAddrs(parseAddrs($b));
          $reply_to = getPref($data_dir, $username, 'reply_to');
          $from = getPref($data_dir, $username, 'full_name');
          $from_addr = getPref($data_dir, $username, 'email_address');
@@ -303,9 +323,9 @@
       global $username, $popuser, $domain, $version, $smtpServerAddress, $smtpPort,
          $data_dir, $color;
 
-      $to = parseAddrs($t);
-      $cc = parseAddrs($c);
-      $bcc = parseAddrs($b);
+      $to = expandAddrs(parseAddrs($t));
+      $cc = expandAddrs(parseAddrs($c));
+      $bcc = expandAddrs(parseAddrs($b));
       $from_addr = getPref($data_dir, $username, 'email_address');
 
       if (!$from_addr)