Skip to content

Commit 7593389

Browse files
authored
Merge pull request #55 from sendpulse/add_retry
add retry send smtp email
2 parents 95432b1 + 69d03ff commit 7593389

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ApiClient.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ApiClient implements ApiInterface
2626
private $token;
2727

2828
private $refreshToken = 0;
29+
private $retry = false;
2930

3031
/**
3132
* @var null|TokenStorageInterface
@@ -1090,6 +1091,13 @@ public function smtpSendMail($email)
10901091

10911092
$requestResult = $this->sendRequest('smtp/emails', 'POST', $data);
10921093

1094+
if ($requestResult->http_code !== 200 && !$this->retry) {
1095+
$this->retry = true;
1096+
sleep(2);
1097+
1098+
$requestResult = $this->smtpSendMail($email);
1099+
}
1100+
10931101
return $this->handleResult($requestResult);
10941102
}
10951103

0 commit comments

Comments
 (0)