From a4102fd7378daec80186e61c8e6fc2fe86cd90c0 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sat, 24 Feb 2001 16:06:18 +0000 Subject: [PATCH] added auto-lookup functionality -- aliases can now be typed in address bars in the compose form. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1155 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 2 ++ functions/smtp.php | 32 ++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 765b20c8..cf5dc575 100644 --- a/ChangeLog +++ b/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 diff --git a/functions/smtp.php b/functions/smtp.php index c4f4dac5..306e0b4d 100644 --- a/functions/smtp.php +++ b/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) -- 2.25.1