Delivery event tracking: bring delivery, bounce and open events back from Amazon SES and Brevo
Describes Emails 0.9.0.
Sending a message is only half the story. Delivery event tracking collects what the provider learns afterwards, such as delivered, bounced, complained, opened or clicked, and writes it onto each email in the log. It is also what feeds the automatic blocklist.
Where to find it
Open Settings → Email Sending and choose the Delivery Event Tracking tab. The address is /admin/settings/email-sending?tab=module_emails_delivery_event_tracking. The tab is shown to people with the Admin or Owner role, or a role with the Emails permission.
A tracker only runs while a matching connection exists in Settings → Integrations and its tracking is turned on.
Delivery events from Amazon SES and Brevo.
The tracker table
There is one row per provider PhoenixKit can track: Amazon SES and Brevo.
- Settings: the arrow opens the row’s own settings below it.
- Provider: the provider’s name.
- Integration: how many connections for it exist, or No integration configured.
- Tracking: turns collection on or off for that provider.
- State: Active (running normally), Idle — no integration (connect a matching integration, and for Amazon SES also make sure SES events are on), Off (tracking is turned off) or Stalled (no check is queued, for example after a lost job). Hover the badge for the explanation.
- Last poll: when events were last fetched, or Never polled yet.
- Queued: background checks waiting to run.
- Accounts: how many of the provider’s accounts are polled, such as 1/2. Click it to open Accounts polled — …, where you can untick an account. An unticked account’s events stay unread until you tick it again.
- Actions: Poll now fetches events right away. Restart appears on a Stalled row and starts the tracker again. The automatic check also fixes a stall within a couple of minutes.
A row’s settings
Every row has Polling interval, in milliseconds: how often PhoenixKit fetches events. The minimum is shown under the field (1,000 ms for Amazon SES, 30,000 ms for Brevo). Brevo has no other settings (This provider has no settings of its own.). Amazon SES has the panel below.
Amazon SES and SQS
Amazon SES doesn’t call PhoenixKit back on its own. It publishes events through a configuration set to an SNS topic, which fills an SQS queue that PhoenixKit reads.
The mailer status at the top says whether the site sends through Amazon SES (Mailer Adapter: Amazon SES with Configured or Not Configured), through another adapter, or has none (No Mailer Adapter Configured Yet). For the last two it shows the config lines a developer would add to switch to SES.
SES credentials source: choose which Amazon SES connection from Settings → Integrations provides the credentials, then press Assign. Credentials, region and verification are set in the connection itself. If sending still uses old credentials stored in settings, a note asks you to create a connection and assign it.
Per-account event tracking: each Amazon SES account polls its own SQS queue with its own credentials.
- Pick a connection in — select an Amazon SES connection — and press Add account.
- On the account’s card, press Setup Infrastructure. PhoenixKit creates the SNS topic, the SQS queue, its dead-letter queue and the SES configuration set in that AWS account, and fills in the fields. The result says AWS infrastructure created for this account. It needs credentials and a region on the connection; without them it says what is missing.
- Or fill in the fields yourself and press Save: SQS Queue URL, SQS Dead Letter Queue URL, SQS Queue ARN, SNS Topic ARN and SES Configuration Set. The configuration set must exist in that same AWS account, because SES publishes events only through it.
Each card shows Active sender or No enabled send profile. Unassign removes the account from event tracking straight away, without asking.
If a sending account has no queue of its own, a warning (Some sending accounts have no event queue of their own) names it: its events are not collected until you add it and set it up. A site set up before per-account tracking may still poll one shared queue; the panel then says which queue it is polling.
SQS Worker Tuning:
- Max Messages Per Poll: how many messages to take from the queue in each cycle, from 1 to 10.
- Visibility Timeout: how long, in seconds, a message stays hidden from other readers after it is taken (30 to 43,200).
The SNS webhook
Instead of, or as well as, polling SQS, Amazon SNS can deliver SES events straight to your site at /webhooks/ses (under your PhoenixKit URL prefix). PhoenixKit confirms the SNS subscription itself and checks each notification: that it is signed by AWS, comes from an AWS address, is recent, and isn’t arriving too fast. Webhook events are recorded the same way as polled ones, including blocking addresses that hard-bounce or complain.
Both routes stop when Process Amazon SES events is off in the Email Tracking tab.
What it doesn’t do
- It tracks Amazon SES and Brevo only. Mail sent through any other adapter gets no delivery events, so it stays at its sent status.
- Unassign removes PhoenixKit’s tracking settings for the account; it doesn’t delete the queue, topic or configuration set in AWS.
- The webhook’s security checks can’t be switched off from the admin.
For developers
The webhook route is added by the module; don’t declare a second one in the host router. Its checks are controlled by the settings webhook_verify_sns_signature, webhook_check_aws_ip and webhook_rate_limit_enabled, all on by default.