Delivery event tracking: bring delivery, bounce and open events back from Amazon SES and Brevo
Describes Emails 0.10.0. On an older release? The version menu above has this guide as it was then.
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. With Amazon SES, opens and clicks are reported only for an account that has Track opens and clicks ticked.
Where to find it
Open Settings → Emails Transactional 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.
- Open IAM policies for this account’s key on the account’s card and give the connection’s AWS key the Setup policy (see below).
- 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. You can now replace the setup policy on the key with the running policy shown with the account. It needs credentials and a region on the connection; without them it says what is missing.
- Replace the setup policy on the key with the Running policy.
- Or, instead of the setup, 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.
IAM policies for this account’s key folds out two policies, each with a Copy button:
- Setup policy: attach it before Setup Infrastructure. It sends, creates the queues, the topic and the configuration set, and reads the queues.
- Running policy: replace the setup policy with it once the setup has succeeded. It sends and reads the queues, and can create nothing.
The key needs nothing else. The policies are written for your site: before the setup, the resource names come from the site’s project title; after it, from what the setup saved, so an account set up under an earlier title still gets a policy that matches its queues. The region is the connection’s; if none is saved yet, the policy shows <region> and a note asks you to replace it or save the connection first. If AWS refuses to let PhoenixKit read an account’s queue, the log says the key needs the running policy.
Track opens and clicks: off unless ticked. With it on, Amazon SES adds a tracking pixel to every message and rewrites every link through its own redirect address, the links of sign-in and password-reset mail included. Save only records the choice; Setup Infrastructure applies it in AWS, so run the setup again after changing 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.
- An account set up before Track opens and clicks existed still tracks opens and clicks in AWS, although its box shows unticked, until Setup Infrastructure is run again.
- The IAM policies and Track opens and clicks appear only on PhoenixKit 3.6 or later.
- 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.