CoolCMS API

EmailQueuePresenter extends BasePresenter
in package

Table of Contents

Constants

DEFAULT_BATCH_SIZE  : mixed = 50
DEFAULT_MAX_ATTEMPTS  : mixed = 5
Maximum send attempts, with backoff of 1 min / 5 min / 30 min / 2 h ({@see EmailQueueManager::RETRY_BACKOFF_MINUTES}): a message survives an SMTP outage of about 2.5 h, then gets `stopped = 1` and the bell notification `EMAIL_QUEUE_FAILED`. Fallback when the setting `email.queue.maxAttempts` is missing or not positive.
DEFAULT_RETENTION_DAYS  : mixed = 30
Retention of processed e-mails in days; fallback when `email.queue.retentionDays` is missing or not positive.
SETTINGS_GROUP  : mixed = 1

Properties

$cronLockManager  : CronLockManager
$operationRunner  : OperationRunner
Boundary of one cron action (see {@see self::tryCall()}).
$settingContext  : SettingContext
$settingManager  : SettingManager
$debugMode  : bool
$productionMode  : bool
$emailQueueManager  : EmailQueueManager

Methods

__construct()  : mixed
actionPurgeOld()  : void
Cleans processed (sent or stopped) e-mails older than N days; newsletter rows stay ({@see EmailQueueManager::purgeProcessedOlderThan()}).
actionSend()  : void
Sends e-mails from the queue gradually.
releaseLock()  : void
Releases the lock at most once; called by both `shutdown()` and the PHP shutdown function.
sendResponse()  : void
setConfigParameters()  : void
shutdown()  : void
startup()  : void
isSameSiteRequest()  : bool
Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.
sendError()  : never
sendSkipped()  : never
Reports that the job did only part of the work and the next call finishes the rest (e.g. a reindex done in chunks).
sendSuccess()  : never
tryCall()  : bool
Runs the `action<Action>()` method as one operation (transitional).
resolveBatchSize()  : int
resolveMaxAttempts()  : int
resolveRetentionDays()  : int

Constants

DEFAULT_MAX_ATTEMPTS

Maximum send attempts, with backoff of 1 min / 5 min / 30 min / 2 h ({@see EmailQueueManager::RETRY_BACKOFF_MINUTES}): a message survives an SMTP outage of about 2.5 h, then gets `stopped = 1` and the bell notification `EMAIL_QUEUE_FAILED`. Fallback when the setting `email.queue.maxAttempts` is missing or not positive.

private mixed DEFAULT_MAX_ATTEMPTS = 5

DEFAULT_RETENTION_DAYS

Retention of processed e-mails in days; fallback when `email.queue.retentionDays` is missing or not positive.

private mixed DEFAULT_RETENTION_DAYS = 30

Properties

$operationRunner

Boundary of one cron action (see {@see self::tryCall()}).

public OperationRunner $operationRunner
Attributes
#[Inject]

Methods

actionPurgeOld()

Cleans processed (sent or stopped) e-mails older than N days; newsletter rows stay ({@see EmailQueueManager::purgeProcessedOlderThan()}).

public actionPurgeOld([int|null $days = null ]) : void

URL: /cron/system/email-queue/purge-old?token=xxx[&days=N]

Retention is ?days, else the setting email.queue.retentionDays (group 1), else 30 days. Frequency: daily.

Parameters
$days : int|null = null
Attributes
#[CronJob]
$frequency: 'daily:04:50'
$outbound: false

actionSend()

Sends e-mails from the queue gradually.

public actionSend() : void

Loads $batchSize unsent e-mails (preferred first, then FIFO by id), sends each separately and updates sent, sendDatetime, errorLog, attempts and stopped by the result. A failed message gets next_attempt_at with a growing delay and is skipped until then.

URL: /cron/system/email-queue/send?token=xxx

Frequency: every minute.

Attributes
#[CronJob]
$frequency: 'every:1'
$outbound: true

releaseLock()

Releases the lock at most once; called by both `shutdown()` and the PHP shutdown function.

public releaseLock() : void

sendResponse()

public sendResponse(Response $response) : void
Parameters
$response : Response

setConfigParameters()

public setConfigParameters([bool $debugMode = false ][, bool $productionMode = false ]) : void
Parameters
$debugMode : bool = false
$productionMode : bool = false

shutdown()

public shutdown(Response $response) : void
Parameters
$response : Response

isSameSiteRequest()

Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.

protected isSameSiteRequest() : bool

getHttpRequest() returns the IRequest interface, while isSameSite() exists only on Nette\Http\Request.

Return values
bool

sendError()

protected sendError(string $message[, int $code = 500 ]) : never
Parameters
$message : string
$code : int = 500
Return values
never

sendSkipped()

Reports that the job did only part of the work and the next call finishes the rest (e.g. a reindex done in chunks).

protected sendSkipped(string $reason[, array<string, mixed> $data = [] ]) : never

The scheduler does not record skipped as a run, so the job stays due and is called again on the next tick.

Parameters
$reason : string
$data : array<string, mixed> = []
Return values
never

sendSuccess()

protected sendSuccess([array<string|int, mixed> $data = [] ]) : never
Parameters
$data : array<string|int, mixed> = []
Return values
never

tryCall()

Runs the `action<Action>()` method as one operation (transitional).

protected tryCall(string $method, array<string, mixed> $params) : bool

Cron has no internalAction*(): its actions call the Api managers directly, so without this in scoped mode nothing would ever empty the unit of work of a cron run. The boundary is the action only; startup() (settings, token, lock) stays outside like the startup of an Api request. A cron action ends with AbortException from send*(), which is a regular end: the outcome comes from the response (ok succeeded, skipped unknown — possibly a part of a batch was done, error failed). Render and signal methods are not wrapped (cron presenters have none).

Parameters
$method : string
$params : array<string, mixed>
Return values
bool
On this page

Search results