Handle 429s for gmail

This commit is contained in:
David Bomba 2023-01-16 13:31:54 +11:00
parent 633537570f
commit 396c5ec21b

View File

@ -65,10 +65,22 @@ class GmailTransport extends AbstractTransport
$body->setRaw($this->base64_encode($bcc_list.$message->toString())); $body->setRaw($this->base64_encode($bcc_list.$message->toString()));
try{
$service->users_messages->send('me', $body, []);
}
catch(Google\Service\Exception $e) {
/* Need to slow down */
if($e->getCode() == '429') {
sleep(5);
$service->users_messages->send('me', $body, []); $service->users_messages->send('me', $body, []);
} }
}
}
private function base64_encode($data) private function base64_encode($data)
{ {
return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '='); return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '=');