An external mail provider, inside Microsoft 365.
How we connected a required mail provider to Outlook: Exchange mail-flow rules, a routing mailbox, Microsoft Graph, IMAP, SMTP and delivery tracking.
Some organisations need to use a particular external provider for part of their email communication. The people handling those messages already work in Microsoft 365. The practical challenge is to bring that required communication channel into the team's everyday workspace.
We built an active mail synchronisation bridge around that requirement. Colleagues work in Outlook, selected outgoing messages travel through the required provider, and incoming mail appears in a shared Microsoft 365 mailbox. The provider identity and connection stay centralised while authorised colleagues use their own Microsoft 365 accounts.
The complete mail flow

Open the flow diagram at full size. The two columns show outgoing and incoming messages. The hidden staging folder belongs to incoming delivery; the routing mailbox holds outgoing work.
How we used the Microsoft 365 mail-flow rules
The first integration point is Exchange Online. We used mail-flow rules to redirect selected outgoing messages into a dedicated routing mailbox. That mailbox is the handover point between the organisation's Microsoft 365 environment and our synchronisation service.
For example, a colleague writes to an external recipient in Outlook. When the message matches the configured routing policy, Exchange delivers it to the routing mailbox. The worker reads that stored message, reconstructs its content and recipients, and submits it through the required provider. The exact addresses and rule conditions remain private.
These are transport rules: they act while mail is in transit. A redirect changes the delivery destination; it is not a user moving a message between Outlook folders. Microsoft's mail-flow rule documentation explains that distinction, and its redirect action reference describes delivery to the selected destination instead of the original recipients.
The original recipient information available in the message is therefore essential to the second delivery step. Our transport adapter handles To, Cc and Bcc data supplied by the source, including a fallback for supported stored Bcc metadata. Information absent from the source cannot be reconstructed. Messages explicitly addressed to the routing mailbox itself are diverted to a skipped folder instead of being submitted externally.
Reading the routing mailbox with Microsoft Graph
Our PHP and Laravel service authenticates to Microsoft Graph using an application identity and the client-credentials flow. It has separately configurable Microsoft 365 mailboxes for reading outgoing mail and writing incoming mail.
The outgoing worker uses Graph delta queries and persists continuation links and discovered message IDs in a database. Discovery and delivery are separate steps. A poll processes a bounded amount of work, and the next poll resumes from the saved position. A restart therefore does not require a complete scan of the mailbox or discard the remaining work.
Graph requests ask for immutable message IDs. Those IDs remain stable across folder moves within the same mailbox, which helps connect discovery, delivery and archiving. Microsoft's immutable ID documentation describes that scope.
Before submission, the worker obtains a database claim and records a delivery-attempt marker on the Graph message. The Graph update uses an ETag condition, so conflicting updates cannot silently overwrite one another. The tracking record carries the claim token, attempt count, source identity and delivery outcome.
Sending through the external provider
The outgoing adapter prepares the complete MIME message before attempting SMTP delivery. It validates recipient addresses, checks that required attachment files exist and have the expected size, and carries over text, HTML, inline content IDs and supported message metadata. A missing attachment stops preparation rather than producing an incomplete outgoing message.
SMTP authentication and STARTTLS connect the worker to the provider transport. The configured provider address becomes the sender identity. Microsoft 365 supplies the team's working environment; the required provider performs the external submission and onward delivery.
We record SMTP recipient outcomes because one submission can produce different results for different recipients. Provider acceptance is recorded separately from mailbox cleanup. If moving an accepted message into the archive folder fails, the worker retries that move without sending the message again. SMTP acceptance confirms the provider handover, not final delivery to a person's inbox.
Bringing incoming mail back into Outlook
The incoming worker reads the provider mailbox over IMAP. It maps each message into a common internal representation: sender, recipients, subject, body, received date and attachments. Where a message lacks a usable Message-ID, a fallback identity includes mailbox context, UIDVALIDITY and UID.
We create the Microsoft 365 copy in a hidden staging folder first. Small attachments are added directly; larger attachments use Graph upload sessions. Only after the required attachments are present and the creation steps have succeeded does the service move the completed message into the configured inbox. This follows the two attachment paths described in Microsoft's Graph attachment guidance.
The destination message receives a source marker, and its remote ID is stored in the delivery record. If an attempt stops partway through, the next eligible attempt can inspect that existing copy and reconcile its attachments. Original message dates and supported read-state metadata are also handled, including refreshes during backfill.
Incoming routing can select another mailbox or folder based on the sender. The JSON routing document is validated and read for each message. Invalid configuration holds delivery for correction. Once a partial delivery exists, retries stay with its recorded destination even if the routing rules subsequently change.
Shared access for the team
The shared Microsoft 365 mailbox is the team's access point. Membership and mailbox permissions determine which colleagues can work with the incoming messages; outgoing access follows the organisation's Exchange permissions and routing policy. Microsoft's shared mailbox overview describes the membership model.
This separates three concerns: people access Microsoft 365 with their own accounts, the worker accesses Graph with its application identity, and the external transport uses its configured provider credentials. Adding a colleague to the authorised team does not require distributing the provider password.
Handling the uncertain cases
A network interruption can leave the application unsure whether a remote system accepted a message. Repeating every failed request would risk duplicate mail. We built explicit handling for that uncertainty:
- Known failures can return to the pending state with increasing retry delays and a bounded attempt count.
- Uncertain submissions and partial recipient acceptance go to review so an operator can reconcile the outcome.
- Database claims coordinate workers, and stale processing claims are surfaced for recovery.
- Confirmed deliveries remain confirmed when later archiving fails; cleanup has its own retry path.
A stable SMTP Message-ID supports traceability, but it is not a guarantee that a remote server will deduplicate repeated submissions. The safeguards depend on recorded outcomes and reconciliation.
An integration we can operate
We also built a central monitoring console for worker heartbeats, Graph/IMAP/SMTP connector health, pending work, review cases and delivery history. Reporting requests are signed, responses are verified against a pinned public key, and the response is bound to the originating request. Backfill and reconciliation tools support recovery and historical imports.
The result is a shared mail workflow built around a required external channel. Our contribution covers the Exchange routing design, the Graph and mail-protocol adapters, message reconstruction, delivery tracking and the operational tools that keep the flow understandable. The synchronisation uses Graph, IMAP and SMTP; the scope here is email transport and mailbox integration.
Need to connect a required communication provider to the way your team already works? We can help design the routing, integration and operational controls.