googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.22k stars 3.52k forks source link

gmail api throwing error when sending email to more then 14 recipient #2451

Closed web95-moon closed 1 year ago

web95-moon commented 1 year ago

Thanks for stopping by to let us know something could be better!

Environment details

Steps to reproduce

N.A

Code example

N.A

Error screenshot:-

https://prnt.sc/BDeMgM3jZLDj

While it's working if the number of recipients less then 14.

Also, I couldn't find anywhere in the documentation that gmail api has limits that it cannot send emails to more than 14 people at a time.

Thanks!

yash30201 commented 1 year ago

Hi @web95-moon

I tried doing the same with 15 recipients and didn't receive any errors. Below is my code :-

$gmail = new Gmail('YOUR_GOOGLE_API_CLIENT_OBJECT');
$messageClient = $gmail->users_messages;
$rawMessageString = "From: <SENDER_EMAIL_ADDRESS>\<r\n";
$rawMessageString .= "To: RECIPIENT_EMAIL_ADDRESSESS\r<\n";
$rawMessageString .= 'Subject: =?utf-8?B?' . base64_encode('Hi everyone') . "?=\r\n";
$rawMessageString .= "MIME-Version: 1.0\r\n";
$rawMessageString .= "Content-Type: text/html; charset=utf-8\r\n";
$rawMessageString .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$mime = rtrim(strtr(base64_encode($rawMessageString), '+/', '-_'), '=');
$gmailMessage = new Message();
$gmailMessage->setRaw($mime);
$gmail->users_messages->send('me', $gmailMessage);
echo 'DONE' . PHP_EOL;

I'm using apiclient v2.13.

This may be a transient error. Can you please try this again and provide some more info on how to reproduce. Thanks

yash30201 commented 1 year ago

Closing this. Please feel free to open if you still happen to face a issue.