public function mailBounceAction()
{
$response = new Response();
$body = $this->request->getRawBody();
$data = @json_decode($body, true);
if (!is_array($data)) {
return $response;
}
$message = Message::fromArray($data);
$validator = new MessageValidator();
if ($validator->isValid($message)) {
$notification = json_decode($message->get('Message'), true);
if (is_array($notification)) {
do {
if (!isset($notification['notificationType'])) {
break;
}
if ($notification['notificationType'] == 'Bounce') {
if (!isset($notification['bounce'])) {
break;
}
$bounce = $notification['bounce'];
if (!isset($bounce['bouncedRecipients']) || !is_array($bounce['bouncedRecipients'])) {
break;
}
foreach ($bounce['bouncedRecipients'] as $recipient) {
$notificationBounce = new NotificationsBounces();
$notificationBounce->email = $recipient['emailAddress'];
$notificationBounce->status = $recipient['status'];
$notificationBounce->diagnostic = $recipient['diagnosticCode'];
$notificationBounce->save();
}
}
} while (0);
}
}
return $response;
}