From aaf9abef1f3d4f8a3c5dc365a4c2c98f5b153831 Mon Sep 17 00:00:00 2001 From: fidian Date: Thu, 10 May 2001 19:16:03 +0000 Subject: [PATCH] * Adds multiple identities ("From:" addresses) * I honestly don't know why this was thought to be so hard. I did it in a couple hours. * ... and nobody in the Twin Cities (Minnesota) wants to hire me. :-) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1350 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + functions/smtp.php | 54 ++++-- src/addrbook_search_html.php | 2 + src/compose.php | 31 +++- src/options.php | 9 +- src/options_identities.php | 319 +++++++++++++++++++++++++++++++++++ src/options_personal.php | 8 + 7 files changed, 406 insertions(+), 18 deletions(-) create mode 100644 src/options_identities.php diff --git a/ChangeLog b/ChangeLog index 9768ea62..0e9a9712 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ Version 1.1.2 -- DEVELOPMENT ---------------------------- +- Support for multiple identities Version 1.1.1 -- April 30, 2001 ------------------------------- diff --git a/functions/smtp.php b/functions/smtp.php index 493276a7..d531f1dc 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -88,16 +88,30 @@ $info['remotefilename'] . "\"\r\n"; $header .= "Content-Disposition: attachment; filename=\"" . $info['remotefilename'] . "\"\r\n"; - $header .= "Content-Transfer-Encoding: base64\r\n\r\n"; - fputs ($fp, $header); - $length += strlen($header); $file = fopen ($attachment_dir . $info['localfilename'], 'r'); - while ($tmp = fread($file, 570)) { - $encoded = chunk_split(base64_encode($tmp)); - $length += strlen($encoded); - fputs ($fp, $encoded); - } + if (substr($filetype, 0, 5) == 'text/' || + $filetype == 'message/rfc822') { + $header .= "\r\n"; + fputs ($fp, $header); + $length += strlen($header); + while ($tmp = fgets($file, 4096)) { + $tmp = str_replace("\r\n", "\n", $tmp); + $tmp = str_replace("\r", "\n", $tmp); + $tmp = str_replace("\n", "\r\n", $tmp); + fputs($fp, $tmp); + $length += strlen($tmp); + } + } else { + $header .= "Content-Transfer-Encoding: base64\r\n\r\n"; + fputs ($fp, $header); + $length += strlen($header); + while ($tmp = fread($file, 570)) { + $encoded = chunk_split(base64_encode($tmp)); + $length += strlen($encoded); + fputs ($fp, $encoded); + } + } fclose ($file); } } @@ -159,7 +173,7 @@ global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT; global $data_dir, $username, $popuser, $domain, $version, $useSendmail; global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR; - global $REMOTE_HOST; + global $REMOTE_HOST, $identity; // Storing the header to make sure the header is the same // everytime the header is printed. @@ -169,9 +183,18 @@ $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'); + if (isset($identity) && $identity != 'default') + { + $reply_to = getPref($data_dir, $username, 'reply_to' . $identity); + $from = getPref($data_dir, $username, 'full_name' . $identity); + $from_addr = getPref($data_dir, $username, 'email_address' . $identity); + } + else + { + $reply_to = getPref($data_dir, $username, 'reply_to'); + $from = getPref($data_dir, $username, 'full_name'); + $from_addr = getPref($data_dir, $username, 'email_address'); + } if ($from_addr == '') $from_addr = $popuser.'@'.$domain; @@ -336,12 +359,15 @@ function sendSMTP($t, $c, $b, $subject, $body, $more_headers) { global $username, $popuser, $domain, $version, $smtpServerAddress, $smtpPort, - $data_dir, $color, $use_authenticated_smtp; + $data_dir, $color, $use_authenticated_smtp, $identity; $to = expandAddrs(parseAddrs($t)); $cc = expandAddrs(parseAddrs($c)); $bcc = expandAddrs(parseAddrs($b)); - $from_addr = getPref($data_dir, $username, 'email_address'); + if (isset($identity) && $identity != 'default') + $from_addr = getPref($data_dir, $username, 'email_address' . $identity); + else + $from_addr = getPref($data_dir, $username, 'email_address'); if (!$from_addr) $from_addr = "$popuser@$domain"; diff --git a/src/addrbook_search_html.php b/src/addrbook_search_html.php index 9ee5a53f..87f1af21 100644 --- a/src/addrbook_search_html.php +++ b/src/addrbook_search_html.php @@ -41,6 +41,8 @@ . '" name=send_to_cc>' . "\n"; echo "' . "\n"; + echo "' . "\n"; echo "\n"; echo "\n"; diff --git a/src/compose.php b/src/compose.php index 674c7af3..6a12f0cb 100644 --- a/src/compose.php +++ b/src/compose.php @@ -189,7 +189,8 @@ $passed_body, $color, $use_signature, $signature, $prefix_sig, $editor_size, $attachments, $subject, $newmail, $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox, - $from_htmladdr_search, $location_of_buttons, $attachment_dir; + $from_htmladdr_search, $location_of_buttons, $attachment_dir, + $username, $data_dir, $identity; $subject = decodeHeader($subject); $reply_subj = decodeHeader($reply_subj); @@ -217,6 +218,34 @@ if ($location_of_buttons == 'top') showComposeButtonRow(); + $idents = getPref($data_dir, $username, 'identities'); + if ($idents != '' && $idents > 1) + { + echo " \n"; + echo " \n"; + echo _("From:"); + echo " \n"; + echo "\n"; + echo " \n"; + echo " \n"; + } echo " \n"; echo " \n"; echo _("To:"); diff --git a/src/options.php b/src/options.php index db4a4725..f78d285b 100644 --- a/src/options.php +++ b/src/options.php @@ -36,9 +36,12 @@ +
+ + + + +
+ +
+ +
+

">
1) + echo _("Identities Defined"); +else + echo _("Identity Defined"); +?>

+ + + + + + + + + + + + + +
+
+ + 1) { + $nameA = 'full_name' . $i; + $nameB = 'full_name' . ($i - 1); + global $$nameA, $$nameB; + $temp = $$nameA; + $$nameA = $$nameB; + $$nameB = $temp; + + $nameA = 'email_address' . $i; + $nameB = 'email_address' . ($i - 1); + global $$nameA, $$nameB; + $temp = $$nameA; + $$nameA = $$nameB; + $$nameB = $temp; + + $nameA = 'email_address' . $i; + $nameB = 'email_address' . ($i - 1); + global $$nameA, $$nameB; + $temp = $$nameA; + $$nameA = $$nameB; + $$nameB = $temp; + + return true; + } + + $i ++; + $name = 'form_for_' . $i; + global $$name; + } + return false; +} + +function LoadInfo(&$n, &$e, &$r, $post) +{ + global $username, $data_dir; + + $n = getPref($data_dir, $username, 'full_name' . $post); + $e = getPref($data_dir, $username, 'email_address' . $post); + $r = getPref($data_dir, $username, 'reply_to' . $post); + + if ($n != '' || $e != '' || $r != '') + return true; +} + +function ShowTableInfo($full_name, $email_address, $reply_to, $post) +{ + global $color; + + $OtherBG = ''; + + if ($post == '') + $OtherBG = ' bgcolor="' . $color[10] . '"'; + + if ($full_name == '' && $email_address == '' && $reply_to == '') + $isEmptySection = true; + else + $isEmptySection = false; + +?> + > + + : + + + + + + > + + : + + + + + + > + + : + + + + + + + + + : + + + + + + + + + + "> + + "> + 1) { +?> + "> + + + +" name=reply_to> + + : + + Edit Advanced Identities + (discards changes made on this form so far) + + +

: -- 2.25.1