[dev] Re: [cvs] commit: imp compose.php

Jon Parise jon@csh.rit.edu
Fri, 3 Nov 2000 19:30:33 -0500


On Fri, Nov 03, 2000 at 06:40:46PM -0500, Chuck Hagenbuch wrote:

> > Alternatively, we can just let the To: line remain blank and change
> > the test so that it allows for an empty To: line if there's a value in
> > the Cc: line.
> 
> This is far preferable, in my opinion, and gets my vote.

Alright, this patch looks pretty clean and is functionally equivalent
to the way that mutt operates.  I'm happy with this behavior.

Index: compose.php
===================================================================
RCS file: /cvs/horde/imp/compose.php,v
retrieving revision 2.215
diff -u -r2.215 compose.php
--- compose.php 2000/11/03 21:35:49     2.215
+++ compose.php 2000/11/04 00:28:05
@@ -602,8 +602,8 @@
     if (isset($attachments_type) && !is_array($attachments_type)) {
         $attachments = array($attachments_type);
     }
-    
-    if ($to && isset($message)) {
+
+    if (isset($message) && (!empty($to) || !empty($cc))) {
         
         $message = str_replace("\r\n", "\n", $message);
         $mime = new MimeMessage($message, $imp['maildomain']);
@@ -639,20 +639,22 @@
         
         $headers['Message-ID'] = '<' . uniqid(time() . '.') . '@' . $SERVER_NAME . '>';
         $headers['Date'] = rfcdate();
-        
-        $to = format_addresses($to);
-        $headers['To'] = $to;
+ 
         $headers['From'] = $from;
-        $recipients = $to;
+        if (!empty($to)) {
+            $to = format_addresses($to);
+            $headers['To'] = $to;
+            $recipients = $to;
+        }
         if ($conf['compose']['allow_cc'] && !empty($cc)) {
             $cc = format_addresses($cc);
             $headers['Cc'] = $cc;
-            $recipients .= ', ' . $cc;
+            $recipients = (empty($recipients)) ? $cc : "$recipients, $cc";
         }
         if ($conf['compose']['allow_bcc'] && !empty($bcc)) {
             $bcc = format_addresses($bcc);
             $headers['Bcc'] = $bcc;
-            $recipients .= ', ' . $bcc;
+            $recipients = (empty($recipients)) ? $bcc : "$recipients, $bcc";
         }
         if (isset($subject) && $subject) {
             $headers['Subject'] = $subject;

-- 
Jon Parise (jon@csh.rit.edu)  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member