email = $email;
$this->bounceId = false;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$str = '';
if (config('services.postmark')) {
$this->account = auth()->user()->account;
$this->postmark = new PostmarkClient(config('services.postmark'));
$str .= $this->loadBounceEvents();
$str .= $this->loadEmailEvents();
}
if (! $str) {
$str = trans('texts.no_messages_found');
}
$response = new stdClass;
$response->str = $str;
$response->bounce_id = $this->bounceId;
return $response;
}
private function loadBounceEvents() {
$str = '';
$response = $this->postmark->getBounces(5, 0, null, null, $this->email, $this->account->account_key);
foreach ($response['bounces'] as $bounce) {
if (! $bounce['inactive'] || ! $bounce['canactivate']) {
continue;
}
$str .= sprintf('%s
', $bounce['subject']);
$str .= sprintf('%s | %s
', $bounce['type'], $this->account->getDateTime($bounce['bouncedat'], true));
$str .= sprintf('%s %s