title: Sending multiple CC's and BCCs with PHP PEAR MAIL
body: <p>I have a project that I am working on at my job and I am using Pear's mailing.  I need to use smtp because we need to be able to track everything from our mailserver.  And users need to be able to log in before sending a company based email.  We cannot use php's mail function fo this.</p>
  
  <p>My problem is that I cant find any documentation on the net for sending CC and Bcc as well as sending multiple BCCs.  It is very easy to do with php' mail funciton .  All you do is add it to the $header variable like so</p>
  
  <pre><code>$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
  $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
  </code></pre>
  
  <p>This is my code for the php function where I use PEAR</p>
  
  <pre><code>function sender_mail($email,$subject,$mailmsg, $cc, $bcc){
  
      include("Mail.php");
      /* mail setup recipients, subject etc */
  
      //DEFAULT VALUE OF FROM 
      $from = "noreply@addata.net";
  
      //GET EMAIL OF USER
      $result = mysql_query("SELECT email, email_pass FROM u_perinfo WHERE user_id = '$_SESSION[uid]'")
      or die("There was an error when grabbing your email information");
      if(mysql_num_rows($result) &gt; 0){
          $row = mysql_fetch_array($result);
          if($row[0] != ''){
              $from = $row[0];
          }
          $email_pass = $row[1];
      }
  
      $recipients = "$email";
      $headers["From"] = "$from";
      $headers["To"] = "$email";
      $headers["Subject"] = $subject;
      $headers["Cc"] = "$cc";  //Line added by Me to see if it works
      $headers["Bcc"] = "$bcc";  //Line added by Me to see if it works
  
  
      //$mailmsg = "Welcome to Addatareference.com! \r\n\r\nBelow is your unique login information.  \r\n\r\n(Please do not share your login information.)$accountinfo";
      /* SMTP server name, port, user/passwd */
      $smtpinfo["host"] = "smtp.emailsrvr.com";
      $smtpinfo["port"] = "25";
      $smtpinfo["auth"] = true;
      $smtpinfo["username"] = "$from";
      $smtpinfo["password"] = "$email_pass";
      /* Create the mail object using the Mail::factory method */
      $mail_object =&amp; Mail::factory("smtp", $smtpinfo);
      /* Ok send mail */
      $mail_object-&gt;send($recipients, $headers, $mailmsg);
  
  }
  </code></pre>
  
  <p>I have been trying to find a solution to this with no real info coming back my way.  If someone could help me out with this I would be greatly appreciated.</p>