72 public static function run($data =
null, array $parameters = [])
77 $data = $request->getPostList()->getRaw(
'data');
79 if (!isset($parameters[
'IGNORE_ITEM_ERRORS']))
81 $parameters[
'ENABLE_ITEM_ERRORS'] = mb_strtoupper($request->get(
'enableItemErrors')) ===
'Y';
84 $instance =
new self();
85 if ($parameters[
'ENABLE_ITEM_ERRORS'])
87 $instance->enableItemErrors();
94 self::giveAnswer(
true,
'No input data.');
99 $data = Json::decode($data);
101 catch (\Exception $exception)
105 if (!is_array($data))
107 self::giveAnswer(
true,
'Wrong data.');
110 if (!isset($data[
'list']) || !is_array($data[
'list']))
112 self::giveAnswer(
true,
'Parameter `list` required.');
115 $instance->processList($data[
'list']);
117 self::giveAnswer(
false, [
'list' => $instance->getCounters()]);
124 'text' => self::$answerExceptions ? $exception->getMessage() :
null,
125 'list' => $instance->getCounters()
218 $this->countItems = count($list);
220 $this->blacklist = [];
221 $this->smtpLimited = [];
222 foreach ($list as $index => $item)
224 $this->countItemsProcessed++;
230 $this->countItemsError++;
235 $this->countItemsError++;
244 Internal\BlacklistTable::insertBatch($this->blacklist);
281 $this->config->unpackId($item[
'id']);
282 if (!$this->config->verifySignature($item[
'sign']))
287 if (!$this->config->getEntityId())
292 $email = $this->address->set($item[
'email'])->getEmail();
298 if (!empty($item[
'sender']) && self::isSmtpLimited($item[
'statusDescription']) )
300 $this->smtpLimited[] = $this->address->set($item[
'sender'])->getEmail();
304 ->setModuleId($this->config->getModuleId())
305 ->setEntityType($this->config->getEntityType())
306 ->setEntityId($this->config->getEntityId())
308 ->setDateSent((
int) $item[
'completedAt'])
309 ->setError(self::isStatusError($item[
'status']))
310 ->setPermanentError(self::isStatusPermanentError($item[
'status']))
311 ->setBlacklistable(self::isBlacklistable($item[
'statusDescription']))
312 ->setDescription($item[
'statusDescription'])
313 ->setMessage($item[
'message']);
315 if ($this->result->isPermanentError() && $this->result->isBlacklistable())
317 $this->blacklist[] = $this->result->getEmail();
320 $this->result->sendEvent();