diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 3c929f00d9ba..80fa507052f0 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -76,7 +76,24 @@ class GmailTransport extends Transport } - $this->gmail->send(); + /** + * Google is very strict with their + * sending limits, if we hit 429s, sleep and + * retry again later. + */ + try{ + + $this->gmail->send(); + + } + catch(\Google\Service\Exception $e) + { + nlog("gmail exception"); + nlog($e->getErrors()); + + sleep(5); + $this->gmail->send(); + } $this->sendPerformed($message); diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 0f291d77e4a4..1b8713cd1034 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -219,7 +219,7 @@ class NinjaMailerJob implements ShouldQueue $google->getClient()->setAccessToken(json_encode($user->oauth_user_token)); //need to slow down gmail requests otherwise we hit 429's - sleep(rand(1,3)); + sleep(rand(2,6)); } catch(\Exception $e) { $this->logMailError('Gmail Token Invalid', $this->company->clients()->first()); diff --git a/routes/api.php b/routes/api.php index e7f71619a675..af8e3393b6be 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Route; -Route::group(['middleware' => ['throttle:10,1', 'api_secret_check']], function () { +Route::group(['middleware' => ['throttle:300,1', 'api_secret_check']], function () { Route::post('api/v1/signup', 'AccountController@store')->name('signup.submit'); Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin'); });