Skip to content

Email Pipelines ​

Email Pipelines connect Phanera to your organisation's email system, allowing responses and messages to be sent from your own email addresses and inbound emails to be received and automatically linked to requests. Configure them in Settings → Email Pipelines.

Ways to send email ​

Phanera has three sources for outbound email, in order of preference:

  • Personal sender — an individual officer connects their own work mailbox (see Your Profile → My email). Responses and messages they send go out from their own address. Once a user has connected a personal mailbox, they can only send via it or via a pipeline — never the platform sender.
  • Pipeline sender — a shared, per-request-type mailbox (e.g. [email protected]) configured here. This is the recommended default for most organisations, since inbound replies are captured on the case automatically.
  • Platform sender — if no personal or pipeline sender applies, Phanera falls back to the built-in platform email sender, from a generic Phanera system address.

When an officer sends a response or message, they choose the Send from source in the send dialog (see Response Draft and Sending). When email is sent automatically (acknowledgements, reminders, digests), the system selects a pipeline as follows:

  1. If the request was originally created from an inbound email on a specific pipeline, that same pipeline is used for all outbound emails on that request.
  2. Otherwise, the system uses the default enabled pipeline for the request's type (see Default sender). This is what happens for requests submitted through the public portal, which have no pipeline of their own.
  3. If no matching pipeline is found, the platform sender is used as a fallback.

INFO

Emails sent via the platform sender come from a generic Phanera address, which may look less professional to requesters. We recommend configuring at least one email pipeline per request type.

Authentication modes ​

Each pipeline authenticates to the mail server in one of two ways:

  • Basic (SMTP/IMAP password) — the pipeline signs in with a username and password. Simple, and fine for mail servers that still allow password authentication.
  • OAuth (Microsoft 365 / Google / custom) — the pipeline signs in to a mailbox using modern OAuth, with no password stored. This is required for Microsoft 365 and Google Workspace tenants that have disabled basic authentication for SMTP/IMAP.

To use OAuth, an administrator first sets up an OAuth mail provider for the organisation, then connects a pipeline's mailbox to it (see Connecting a pipeline mailbox with OAuth).

General Settings ​

Each pipeline is configured with the following general settings:

  • Name — a descriptive name for the pipeline (e.g. "FOI Enquiries")
  • Request Type — which type of request is created when an email arrives via this pipeline's IMAP connection
  • Enabled toggle — turn the pipeline on or off without deleting its configuration
  • Default sender — marks this pipeline as the default outbound sender for its request type (see Default sender)

Default sender ​

You can have more than one pipeline for the same request type — for example two inbound addresses that both create FOI requests. When that happens, Phanera needs to know which one to send from for requests that aren't tied to a specific pipeline (such as those created on the public portal). The Default sender checkbox controls this.

  • Each request type has exactly one default pipeline. Ticking Default sender on a pipeline automatically clears it on the others for that request type.
  • The first pipeline you create for a request type becomes its default automatically.
  • Requests created from an inbound email always reply through the pipeline they arrived on, regardless of the default.
  • The default pipeline is marked with a Default badge in the pipelines table.

If no pipeline is explicitly marked as default (for example after an import), the oldest enabled pipeline for the request type is used, so routing is always deterministic.

SMTP Settings (Outbound) ​

Configure how Phanera sends emails via this pipeline:

  • Host — your SMTP server hostname (e.g. smtp.office365.com)
  • Port — SMTP port (typically 587 for STARTTLS or 465 for implicit SSL)
  • Enable TLS — whether to use TLS encryption (strongly recommended)
  • Username — SMTP authentication username
  • Password — SMTP authentication password (stored securely; in production environments, passwords are stored in Azure Key Vault rather than the database)
  • From Address — the email address emails are sent from (e.g. [email protected])
  • From Display Name — the sender name displayed to recipients (e.g. "FOI Team")
  • Reply-To Address — the address replies are directed to (optional; if not set, replies go to the From Address)

Click Verify SMTP to perform a real connection and authentication test before saving. The test has a 30-second timeout.

IMAP Settings (Inbound) ​

Configure how Phanera checks for incoming emails:

  • Host — your IMAP server hostname (e.g. outlook.office365.com)
  • Port — IMAP port (typically 993 for SSL)
  • Enable TLS — whether to use SSL/TLS on connect
  • Username — IMAP authentication username (if not set, falls back to the SMTP username)
  • Password — IMAP authentication password (if not set, falls back to the SMTP password)

Click Verify IMAP to perform a real connection and authentication test before saving.

INFO

When a pipeline is connected with OAuth, the SMTP and IMAP passwords on this screen are not used — sending (and inbound polling, when enabled) authenticate with the connected mailbox's OAuth token instead. For Microsoft 365 and Google, the SMTP/IMAP hosts and ports are filled in automatically from the provider. Whether an OAuth pipeline reads incoming mail is controlled by the Read incoming email option in the OAuth connect flow — see Connecting a pipeline mailbox with OAuth.

OAuth Mail Providers ​

Administrators with the Manage Mail Providers permission configure organisation OAuth providers at the bottom of Settings → Email Pipelines. A provider is the OAuth application that mailboxes (both pipelines and personal senders) authenticate against. You set one up once per organisation.

Each provider has:

  • Provider type — Microsoft 365, Google Workspace, or Custom (any OAuth2 provider)
  • Display name — shown to users when they connect a mailbox
  • Tenant ID — (Microsoft 365 only) your Entra / Azure AD directory tenant ID
  • Client ID and Client secret — from the OAuth application you register with your identity provider
  • Custom providers also require the authorization endpoint, token endpoint, scopes, and SMTP/IMAP hosts and ports

The dialog shows the redirect URI you must register in your OAuth application. This is always on the API host, not the address bar of the admin app — for the hosted service it is:

https://api.phanera.co.uk/api/mail-connections/callback

The value must match exactly (scheme, host and path), because Phanera uses the same URI both to start the sign-in and to exchange the authorization code. A mismatch produces a redirect_uri_mismatch error from the identity provider. The provider dialog fills this in for you based on the API host the admin app is talking to; register that value verbatim. If you run Phanera on your own domain, substitute your API host.

Registering the app

For Microsoft 365, register an app in Entra ID with delegated permissions for IMAP (IMAP.AccessAsUser.All), SMTP (SMTP.Send) and offline_access, add the redirect URI above as a Web platform redirect, and create a client secret. For Google Workspace, create an OAuth client (type Web application) in Google Cloud with the Gmail scope (https://mail.google.com/) and offline access, and add the same redirect URI to the client's Authorized redirect URIs. The client secret is stored in Azure Key Vault in production.

A provider cannot be deleted while any personal connection or pipeline is still using it.

Connecting a pipeline mailbox with OAuth ​

Once at least one OAuth provider exists, there are two ways to set up an OAuth pipeline.

When creating a new pipeline ​

The Add Pipeline dialog shows an Authentication choice at the top:

  • SMTP username & password — the classic flow: enter and verify SMTP (and optionally IMAP) credentials.
  • OAuth sign-in (Microsoft 365 / Google) — no SMTP/IMAP hosts, passwords or verification steps. You only provide the name, request type, inbound address, an optional display name, and pick the provider.

When OAuth is chosen, click Save & sign in: the pipeline is created and you are immediately redirected to the identity provider to sign in as the mailbox. On return, the pipeline shows an OAuth badge.

Connecting an existing pipeline ​

Each pipeline row also shows a Connect mailbox (OAuth) action:

  1. Click the OAuth connect icon on the pipeline.
  2. Choose the provider and click Sign in & connect.
  3. You are redirected to your identity provider to sign in as the pipeline's shared mailbox (e.g. [email protected]) and grant access.
  4. On return, the pipeline shows an OAuth badge. Sending now uses OAuth.

Send-only vs. reading (IMAP) ​

Both flows include a Read incoming email (IMAP polling) checkbox, which mirrors how basic-auth pipelines behave (a pipeline reads only when IMAP is configured):

  • Checked — the pipeline both sends and polls the mailbox for inbound email. Phanera stores the provider's IMAP host on the pipeline automatically (e.g. outlook.office365.com for Microsoft 365) so no host needs to be entered.
  • Unchecked — the pipeline is send-only; no inbound polling takes place.

When connecting an existing pipeline, the checkbox defaults to that pipeline's current state (on if it already reads, off if it was send-only). You can also change it at any time from the pipeline's Edit dialog, without reconnecting.

Editing an OAuth-connected pipeline shows only its general and sender settings (name, request type, inbound address, from address, display name, reply-to, the Read incoming email toggle, and the enabled/default toggles) — there are no SMTP/IMAP password fields, because none are used. You can turn inbound reading on or off directly here; to change the connected mailbox or switch provider, reconnect the pipeline (or use Disconnect OAuth first).

If you choose OAuth when creating a pipeline but the sign-in doesn't complete, the pipeline is saved in a not-connected state (shown with an "OAuth · not connected" badge). Use the connect action on its row to finish signing in — it will not send or read mail until connected.

To revert a pipeline to password authentication, use the Disconnect OAuth action on the pipeline row — it restores basic SMTP/IMAP auth using the pipeline's stored settings.

Inbound Email Polling ​

When IMAP is configured, Phanera automatically polls for new emails every 30 seconds. The pipeline status area shows:

  • Last Polled — the timestamp of the last successful poll
  • Polling Error — any error message from the most recent failed poll
  • Polling Error At — the timestamp of the last error

When a new pipeline is first polled, the system bookmarks the current mailbox position. Only emails arriving after the pipeline is created are processed — existing emails in the mailbox are not imported.

If polling encounters 3 consecutive failures, the pipeline is automatically paused to prevent repeated errors. The polling error is displayed on the pipeline. Use the Restart Polling button to clear the error and resume polling.

WARNING

Restarting polling clears the error and resumes from where it left off. If the underlying issue (e.g. expired credentials) is not resolved, polling will fail and pause again after 3 more attempts.

Inbound Email Webhook ​

Polling is not the only way mail reaches Phanera. If your mail provider can forward parsed incoming email over HTTP — SendGrid Inbound Parse, Mailgun Routes and similar — it can post directly to Phanera instead of, or alongside, IMAP polling. Delivery is immediate rather than on the 30-second poll cycle, and there are no IMAP credentials to keep working.

The endpoint is:

POST https://your-phanera-host/api/webhooks/email/inbound?secret=YOUR_SECRET

It expects multipart/form-data in the shape SendGrid Inbound Parse sends: from, to, subject, text, and optionally message-id, in-reply-to, date and file attachments.

Phanera decides which pipeline the mail belongs to by matching the payload's to address against each pipeline's Inbound Address. Nothing else about the pipeline needs configuring for the webhook — no IMAP host, port or password.

The shared secret ​

The webhook is protected by a shared secret held in the server configuration, under the key EmailIngress:WebhookSecret. You append it to the URL as a ?secret= query parameter, and your mail provider sends it with every delivery.

The webhook does nothing until the secret is set

If EmailIngress:WebhookSecret is not configured, the endpoint refuses every delivery and no requests are created from it. This is deliberate: an unauthenticated endpoint that writes to your case records is not something the platform will leave open. There is no pipeline setting that can change it — the key must be set on the server.

The Email Pipelines screen shows a warning banner while the secret is missing, and shows you the URL to give your provider once it is set. IMAP polling is unaffected either way.

Two further things worth knowing:

  • The secret travels in the query string, so it appears in web-server access logs and in any proxy or CDN in front of Phanera. Treat it as a long-lived credential with a wide blast radius: restrict who can read those logs, and rotate it if a log export leaves your control.
  • An inbound address must be unique across the whole platform for webhook delivery to work. If the same address is configured on pipelines in two different organisations, Phanera refuses the delivery rather than guessing which authority the mail belongs to.

Choosing between polling and the webhook ​

IMAP pollingWebhook
SetupIMAP host, port and credentials (or OAuth) on each pipelineOne server-side secret, plus a route configured at your mail provider
LatencyUp to 30 secondsImmediate
Credentials to maintainIMAP password or OAuth token per mailboxOne shared secret
Fails whenCredentials expire; the pipeline pauses after 3 failuresThe secret is missing or wrong

Most organisations use polling, because it works against any mailbox without involving the mail provider's routing configuration. The webhook suits deployments already routing mail through a provider that offers it.

How Inbound Emails Are Processed ​

This applies to mail arriving by either route — IMAP polling or the webhook. When a new email arrives, the system processes it as follows:

  1. The system checks whether the email can be matched to an existing request — first by looking for a reference number in the subject line, then by checking the In-Reply-To header to match a previous outgoing message. Subject-line matching recognises both the current REQ-ABC-2026-00001 format and the older type-coded references (FOI-ABC-2026-00001), so threading keeps working for requests created before the format changed.
  2. The system determines whether the sender is a staff member in your organisation or an external requester.
  3. Based on these checks, the email is routed:
    • Existing request + external sender → the email is added as a requester reply on that request
    • Existing request + staff sender → the email is added as a staff message on that request
    • No matching request + external sender → a new request is created with Source set to "Email", the request type configured on the pipeline, and an acknowledgement email is automatically sent to the requester
    • Staff sender + no matching request → the email is logged but no action is taken

Any file attachments on the inbound email are uploaded and linked to the request (subject to your organisation's storage quota).

Replies reopen a closed request

If an inbound reply matches a request that has already been closed, the request is automatically reopened so the new correspondence isn't missed. It returns to In progress if it still has an assignee, or to Received (unassigned) if it doesn't, and a Request reopened entry is added to its timeline. A requester reply only reopens a case when the sender's address matches the requester on file; transferred requests are never reopened.

Email Threading ​

Phanera sets standard email threading headers (Message-ID, In-Reply-To, References) on all outbound emails. This means that replies from requesters are threaded correctly in their email client and can be automatically matched back to the correct request when they arrive via IMAP.

When sent via a pipeline, the Message-ID uses your email domain. When sent via the platform sender, the Message-ID uses the platform domain.

Email Types Sent ​

The following email types are sent through pipelines (or the platform sender):

  • Acknowledgement — automatic confirmation when a request is received (via portal or email)
  • Response — the formal response to a request, including any response draft file attachments
  • Message — ad-hoc messages sent to requesters or other parties
  • Clarification Request — sent when the clock is stopped for clarification
  • Fee Notice — sent when a fee notice is issued
  • Transfer Notification — sent to the requester when a request is transferred to another authority
  • Assignment Notification — sent to staff when assigned to a request (individual or bulk)
  • New Request Notification — sent to eligible staff as soon as a new request arrives
  • Reminder — deadline reminder emails sent at the configured reminder day intervals
  • Overdue Digest — the daily request digest sent to eligible staff each working morning
  • Blocker Raised / Blocker Escalated — notifications about request blockers
  • Milestone Missed — notification when a request milestone passes its internal due date

Phanera — FOI, SAR, EIR & Complaints management