More checks in the bounce cron job.

This commit is contained in:
James Cole
2015-08-19 19:21:39 +02:00
parent a65d609fdc
commit 21b6ad7a41

View File

@@ -25,7 +25,16 @@ class CronController extends Controller
if (strlen(env('SENDGRID_USERNAME')) > 0 && strlen(env('SENDGRID_PASSWORD')) > 0) {
$URL = 'https://api.sendgrid.com/api/bounces.get.json';
$set = [
'blocks' => 'https://api.sendgrid.com/api/blocks.get.json',
'bounces' => 'https://api.sendgrid.com/api/bounces.get.json',
'invalids' => 'https://api.sendgrid.com/api/invalidemails.get.json',
];
echo '<pre>';
foreach ($set as $name => $URL) {
$parameters = [
'api_user' => env('SENDGRID_USERNAME'),
'api_key' => env('SENDGRID_PASSWORD'),
@@ -39,7 +48,7 @@ class CronController extends Controller
* Loop the result, if any.
*/
if (is_array($data)) {
echo 'Found ' . count($data) . ' entries in the SendGrid bounce list.' . "\n";
echo 'Found ' . count($data) . ' entries in the SendGrid ' . $name . ' list.' . "\n";
foreach ($data as $entry) {
$address = $entry->email;
$user = User::where('email', $address)->where('blocked', 0)->first();
@@ -54,6 +63,7 @@ class CronController extends Controller
}
}
}
}
echo 'Done!' . "\n";
} else {
echo 'Please fill in SendGrid details.';