title: Add Bcc to email sent with Gmail API with PHP
body: <p>So, I followed everything is this <a href="https://developers.google.com/gmail/api/quickstart/php" rel="nofollow noreferrer">guide</a>, and yes, I was able to send emails, but I'm trying to add Bcc emails, because its a very long list and I dont want them to show in the email's recipients list.</p>
  
  <p>When sending with PHPMailer everything is fine, this <a href="https://stackoverflow.com/questions/28779854/how-to-send-to-bcc-address-when-using-phpmailer-to-format-mime-message-for-gmail?rq=1">question</a> seems to have the answer to my problem, but as much as I have tried, I haven't found an answer.</p>
  
  <p>How I'm doing it right now:</p>
  
  <pre><code>$client = getClient();
  if (is_string($client)){
      exit ($client);
  }
  $service = new Google_Service_Gmail($client);
  $user = 'me';
  
  $strSubject = 'Correo GMail API' . date('M d, Y h:i:s A');
  $strRawMessage = "From: Lauro Campos&lt;jlcampost@concredito.com.mx&gt;\r\n";
  $strRawMessage .= "To: Metro Gio &lt;greyeso@concredito.com.mx&gt;\r\n";
  $strRawMessage .= "Bcc: &lt;cjlindorv@concredito.com.mx&gt;,&lt;cfgonzalezr@concredito.com.mx&gt;,&lt;jlcampost@concredito.com.mx&gt;\r\n";
  $strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode($strSubject) . "?=\r\n";
  $strRawMessage .= "MIME-Version: 1.0\r\n";
  $strRawMessage .= "Content-Type: text/html; charset=utf-8\r\n";
  $strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
  $strRawMessage .= "mensaje &lt;b&gt;de prueba!\r\n";
  // The message needs to be encoded in Base64URL
  $mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
  $msg = new Google_Service_Gmail_Message();
  $msg-&gt;setRaw($mime);
  //The special value **me** can be used to indicate the authenticated user.
  $service-&gt;users_messages-&gt;send("me", $msg);
  </code></pre>
  
  <p>The email does get sent and every recipient gets the email, BUT Bcc are shown in the email recipient list as:</p>
  
  <pre><code>para Metro, bcc: cjlindorv, bcc: cfgonzalezr, bcc: mí
  </code></pre>
  
  <p>When I use PHPMailer sending through SMTP, and use email->AddBCC() method, in the email only the address added in $email->AddAddress() method is shown:</p>
  
  <pre><code>para Metro
  </code></pre>
  
  <p>I want to do the same but with Gmail API, like I said, this <a href="https://stackoverflow.com/questions/28779854/how-to-send-to-bcc-address-when-using-phpmailer-to-format-mime-message-for-gmail?rq=1">question</a> seems to have the answer, but I need more information. </p>
  
  <p>He says:</p>
  
  <pre><code>You didn't provide your GMAIL API code but it might follow this outline:
  
  $message = new Message();
  
  # construct message using raw data from PHPMailer
  $message-&gt;setSubjectBody(...);
  $message-&gt;setTextBody(...);
  $message-&gt;setHtmlBody(...);
  
  # *** add the BCC recipients here ***
  $message-&gt;addBcc("secret.recipient@google.com");
  
  # send the message
  $message-&gt;send();
  </code></pre>
  
  <p>I would think that the Message() class he is talking about would be Google_Service_Gmail_Message(), but it doesn't contain such methods, this is where I'm missing something.</p>
  
  <p>Can anyone help please?</p>