From 93555af8c63685011700a2b5036a432d24e818f7 Mon Sep 17 00:00:00 2001 From: ullgren Date: Sat, 10 Nov 2001 21:22:30 +0000 Subject: [PATCH] Fixed bug #431256 - Alias expanded not RFC 821-compatible git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1717 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/smtp.php | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/functions/smtp.php b/functions/smtp.php index 153f15e5..92ab7f72 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -68,6 +68,35 @@ return $array; } + + // looks up aliases in the addressbook and expands them to + // the RFC 821 valid RCPT address. ie + // Adds @$domain if it wasn't in the address book and if it + // doesn't have an @ symbol in it + function expandRcptAddrs ($array) { + global $domain; + + // don't show errors -- kinda critical that we don't see + // them here since the redirect won't work if we do show them + $abook = addressbook_init(false); + for ($i=0; $i < count($array); $i++) { + $result = $abook->lookup($array[$i]); + $ret = ""; + if (isset($result['email'])) { + $ret = '<'.$result['email'].'>'; + $array[$i] = $ret; + } + else + { + if (strpos($array[$i], '@') === false) + $array[$i] .= '@' . $domain; + $array[$i] = '<' . $array[$i] . '>'; + } + } + return $array; + } + + // Attach the files that are due to be attached function attachFiles ($fp) { global $attachments, $attachment_dir; @@ -369,9 +398,9 @@ $smtpPort, $data_dir, $color, $use_authenticated_smtp, $identity, $key, $onetimepad; - $to = expandAddrs(parseAddrs($t)); - $cc = expandAddrs(parseAddrs($c)); - $bcc = expandAddrs(parseAddrs($b)); + $to = expandRcptAddrs(parseAddrs($t)); + $cc = expandRcptAddrs(parseAddrs($c)); + $bcc = expandRcptAddrs(parseAddrs($b)); if (isset($identity) && $identity != 'default') $from_addr = getPref($data_dir, $username, 'email_address' . $identity); else -- 2.25.1