PHP Gmail API: can send email, but how to add recipient email address

I have a working gmail api php code captured from https://github.com/google/google-api-php-client/

I can send an email with the following code, but without a recipient. In sent gmail messages, I also see the message sent!

$mime = rtrim(strtr(base64_encode($_POST["message"]), '+/', '-_'), '=');
$msg = new Google_Service_Gmail_Message();
$msg->setRaw($mime);
$x = $service->users_messages->send("me", $msg);

How to add recipient email address? In several posts I read what Toshould be added to the headline.

+4
source share

All Articles