Index: /trunk/roundcubemail/CHANGELOG
===================================================================
--- /trunk/roundcubemail/CHANGELOG	(revision 5400)
+++ /trunk/roundcubemail/CHANGELOG	(revision 5401)
@@ -2,4 +2,5 @@
 ===========================
 
+- Make email recipients separator configurable
 - Fix so folders with \Noinferiors attribute aren't listed in parent selector
 - Fix handling of curly brackets in URLs (#1488168)
Index: /trunk/roundcubemail/config/main.inc.php.dist
===================================================================
--- /trunk/roundcubemail/config/main.inc.php.dist	(revision 5400)
+++ /trunk/roundcubemail/config/main.inc.php.dist	(revision 5401)
@@ -6,5 +6,5 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2010, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
@@ -460,4 +460,7 @@
 // Makes that words with symbols will be ignored (e.g. g@@gle)
 $rcmail_config['spellcheck_ignore_syms'] = false;
+
+// Use this char/string to separate recipients when composing a new message
+$rcmail_config['recipients_separator'] = ',';
 
 // don't let users set pagesize to more than this value if set
Index: /trunk/roundcubemail/program/js/app.js
===================================================================
--- /trunk/roundcubemail/program/js/app.js	(revision 5400)
+++ /trunk/roundcubemail/program/js/app.js	(revision 5401)
@@ -21,5 +21,5 @@
 function rcube_webmail()
 {
-  this.env = {};
+  this.env = { recipients_separator:',', recipients_delimiter:', ' };
   this.labels = {};
   this.buttons = {};
@@ -2927,4 +2927,6 @@
   this.init_address_input_events = function(obj, props)
   {
+    this.env.recipients_delimiter = this.env.recipients_separator + ' ';
+
     obj[bw.ie || bw.safari || bw.chrome ? 'keydown' : 'keypress'](function(e) { return ref.ksearch_keydown(e, this, props); })
       .attr('autocomplete', 'off');
@@ -3591,5 +3593,5 @@
     // insert all members of a group
     if (typeof this.env.contacts[id] === 'object' && this.env.contacts[id].id) {
-      insert += this.env.contacts[id].name + ', ';
+      insert += this.env.contacts[id].name + this.env.recipients_delimiter;
       this.group2expand = $.extend({}, this.env.contacts[id]);
       this.group2expand.input = this.ksearch_input;
@@ -3597,5 +3599,5 @@
     }
     else if (typeof this.env.contacts[id] === 'string') {
-      insert = this.env.contacts[id] + ', ';
+      insert = this.env.contacts[id] + this.env.recipients_delimiter;
       trigger = true;
     }
@@ -3634,5 +3636,5 @@
     // get string from current cursor pos to last comma
     var cpos = this.get_caret_pos(this.ksearch_input),
-      p = inp_value.lastIndexOf(',', cpos-1),
+      p = inp_value.lastIndexOf(this.env.recipients_separator, cpos-1),
       q = inp_value.substring(p+1, cpos),
       min = this.env.autocomplete_min_length,
Index: /trunk/roundcubemail/program/steps/mail/autocomplete.inc
===================================================================
--- /trunk/roundcubemail/program/steps/mail/autocomplete.inc	(revision 5400)
+++ /trunk/roundcubemail/program/steps/mail/autocomplete.inc	(revision 5401)
@@ -33,5 +33,6 @@
     }
 
-    $OUTPUT->command('replace_group_recipients', $gid, join(', ', $members));
+    $separator = trim($RCMAIL->config->get('recipients_separator', ',')) . ' ';
+    $OUTPUT->command('replace_group_recipients', $gid, join($separator, array_unique($members)));
   }
 
@@ -71,6 +72,6 @@
             continue;
           }
-          // when we've got more than one book, we need to skip duplicates
-          if ($books_num == 1 || !in_array($contact, $contacts)) {
+          // skip duplicates
+          if (!in_array($contact, $contacts)) {
             $contacts[] = $contact;
             if (count($contacts) >= $MAXNUM)
Index: /trunk/roundcubemail/program/steps/mail/compose.inc
===================================================================
--- /trunk/roundcubemail/program/steps/mail/compose.inc	(revision 5400)
+++ /trunk/roundcubemail/program/steps/mail/compose.inc	(revision 5401)
@@ -6,5 +6,5 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
@@ -123,6 +123,7 @@
 // set current mailbox in client environment
 $OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name());
-$OUTPUT->set_env('sig_above', $CONFIG['sig_above']);
-$OUTPUT->set_env('top_posting', $CONFIG['top_posting']);
+$OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false));
+$OUTPUT->set_env('top_posting', $RCMAIL->config->get('top_posting', false));
+$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
 
 // get reference message and set compose mode
@@ -325,4 +326,5 @@
 $a_recipients = array();
 $parts        = array('to', 'cc', 'bcc', 'replyto', 'followupto');
+$separator    = trim($RCMAIL->config->get('recipients_separator', ',')) . ' ';
 
 foreach ($parts as $header) {
@@ -368,5 +370,5 @@
         $fvalue .= $v;
       if ($v = $MESSAGE->headers->cc)
-        $fvalue .= (!empty($fvalue) ? ', ' : '') . $v;
+        $fvalue .= (!empty($fvalue) ? $separator : '') . $v;
     }
   }
@@ -411,5 +413,5 @@
     }
 
-    $fvalue = implode(', ', $fvalue);
+    $fvalue = implode($separator, $fvalue);
   }
 
Index: /trunk/roundcubemail/program/steps/mail/sendmail.inc
===================================================================
--- /trunk/roundcubemail/program/steps/mail/sendmail.inc	(revision 5400)
+++ /trunk/roundcubemail/program/steps/mail/sendmail.inc	(revision 5401)
@@ -6,5 +6,5 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2010, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
@@ -139,14 +139,22 @@
 }
 
-// parse email address input (and count addresses)
+/**
+ * Parse and cleanup email address input (and count addresses)
+ *
+ * @param string  Address input
+ * @param boolean Do count recipients (saved in global $RECIPIENT_COUNT)
+ * @param boolean Validate addresses (errors saved in global $EMAIL_FORMAT_ERROR)
+ * @return string Canonical recipients string separated by comma
+ */
 function rcmail_email_input_format($mailto, $count=false, $check=true)
 {
-  global $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT;
+  global $RCMAIL, $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT;
 
   // simplified email regexp, supporting quoted local part
   $email_regexp = '(\S+|("[^"]+"))@\S+';
 
-  $regexp  = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/', '/(\S{1})(<'.$email_regexp.'>)/U');
-  $replace = array(', ', ', ', '', ',', '\\1 \\2');
+  $delim = trim($RCMAIL->config->get('recipients_separator', ','));
+  $regexp  = array("/[,;$delim]\s*[\r\n]+/", '/[\r\n]+/', "/[,;$delim]\s*\$/m", '/;/', '/(\S{1})(<'.$email_regexp.'>)/U');
+  $replace = array($delim.' ', ', ', '', $delim, '\\1 \\2');
 
   // replace new lines and strip ending ', ', make address input more valid
@@ -154,5 +162,5 @@
 
   $result = array();
-  $items = rcube_explode_quoted_string(',', $mailto);
+  $items = rcube_explode_quoted_string($delim, $mailto);
 
   foreach($items as $item) {
@@ -169,14 +177,7 @@
     } else if (preg_match('/<*'.$email_regexp.'>*$/', $item, $matches)) {
       $address = $matches[0];
-      $name = str_replace($address, '', $item);
-      $name = trim($name);
-      if ($name && ($name[0] != '"' || $name[strlen($name)-1] != '"')
-          && preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name)) {
-            $name = '"'.addcslashes($name, '"').'"';
-      }
+      $name = trim(str_replace($address, '', $item), '" ');
       $address = rcube_idn_to_ascii(trim($address, '<>'));
-      $address = '<' . $address . '>';
-
-      $result[] = $name.' '.$address;
+      $result[] = format_email_recipient($address, $name);
       $item = $address;
     } else if (trim($item)) {
