---
title: "Send app email through Microsoft 365 from a server · CloudSat"
description: "Send app email through Microsoft 365 from a server: SMTP AUTH with OAuth, High Volume Email or Direct Send, and the December 2026 change to Basic auth."
url: https://cloudsat.io/learn/send-app-email-through-microsoft-365
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Networking](https://cloudsat.io/learn/topic/networking-and-dns)

# Send app email through Microsoft 365 from a server

Send app email through Microsoft 365 from a server: SMTP AUTH with OAuth, High Volume Email or Direct Send, and the December 2026 change to Basic auth.

CloudSat team November 18, 2026 8 min read

Your application runs on a VPS, but your domain's mailboxes live in Microsoft 365, and password resets, invoices and alerts should leave from an address like `noreply@contoso.com`. Microsoft documents four ways for applications to send through Exchange Online. They differ in who may receive the mail, which port they use and how they sign in, and one of them is not supported for applications hosted by a third party. The setup most older guides describe, a mailbox password over SMTP AUTH, is switched off by default for existing tenants at the end of December 2026.

## The four routes at a glance

| Route | Endpoint and port | Sign-in | Recipients | From a rented server |
| --- | --- | --- | --- | --- |
| SMTP AUTH (client submission) | `smtp.office365.com`, 587 with STARTTLS | Mailbox credentials, OAuth recommended | Anyone | Yes |
| High Volume Email (HVE) | `smtp.hve.mx.microsoft`, 587 | HVE account password or OAuth | Your tenant only | Yes |
| Direct Send | Your MX endpoint, 25 | None | Your tenant only | Yes, with port 25 and SPF |
| SMTP relay connector | Your MX endpoint, 25 | Certificate or static IP | Anyone | Not supported |

Choose by recipient first. Mail for customers or anyone outside the tenant leaves one route on this list, SMTP AUTH, plus services built for external volume (covered below). Mail that only goes to staff, such as alerts, reports and job results, fits HVE.

The limits differ too. SMTP AUTH inherits mailbox limits: 10,000 recipients per day and 30 messages per minute, and copies land in the mailbox's Sent Items. HVE has no recipient or message rate limits, but caps each message at 50 recipients and 10 MB, and it is billed per delivered recipient through Microsoft 365 pay-as-you-go billing linked to an Azure subscription.

## What changes in December 2026

Microsoft's current timeline for Basic authentication on SMTP AUTH:

- **Until the end of December 2026**: nothing changes.
- **End of December 2026**: Basic auth is disabled by default for existing tenants. Admins can still turn it back on.
- **Tenants created after December 2026**: Basic auth is unavailable by default.
- **Second half of 2027**: Microsoft announces the final removal date.

An app that stores a mailbox password stops sending on the day the default flips, unless an admin re-enables Basic auth, and that override has an end date coming. Switch to OAuth while both methods still work, so you can test without an outage. Two related defaults catch people out: SMTP AUTH is disabled for organizations created after January 2020 and must be enabled per mailbox, and tenants that use Microsoft Entra security defaults have SMTP AUTH turned off entirely.

## SMTP AUTH with OAuth for a background service

An unattended service cannot click through a sign-in page, so it uses the OAuth client credentials flow: the application proves its identity with a secret or a certificate, and Exchange decides which mailbox it may send as.

1. In the Microsoft Entra admin center, register a single-tenant application. Under **API permissions**, add the **Office 365 Exchange Online** application permission **SMTP.SendAsApp**, then grant admin consent.
2. Add a certificate or a client secret. Both expire, so record the date where someone will see it.
3. Register the application's service principal in Exchange Online, give it access to one licensed mailbox reserved for the app, and enable SMTP AUTH on that mailbox only.

```powershell
Connect-ExchangeOnline
New-ServicePrincipal -AppId "<application-id>" -ObjectId "<enterprise-app-object-id>" -DisplayName "smtp-billing-app"
$sp = Get-ServicePrincipal -Identity "smtp-billing-app"
Add-MailboxPermission -Identity "noreply@contoso.com" -User $sp.Identity -AccessRights FullAccess
Set-CASMailbox -Identity "noreply@contoso.com" -SmtpClientAuthenticationDisabled $false
```

The object ID comes from the app's page under **Enterprise applications**, not from **App registrations**. Using the wrong one is the most common reason authentication fails later. If the app must send as a different address than the mailbox it signs in with, grant **Send As** with `Add-RecipientPermission` as well.

The application then requests a token with the scope `https://outlook.office365.com/.default` and passes it to the server with the SASL XOAUTH2 mechanism. In Python, with the `msal` package:

```python
import os
import smtplib
from email.message import EmailMessage

import msal

SENDER = "noreply@contoso.com"
app = msal.ConfidentialClientApplication(
    os.environ["M365_CLIENT_ID"],
    authority=f"https://login.microsoftonline.com/{os.environ['M365_TENANT_ID']}",
    client_credential=os.environ["M365_CLIENT_SECRET"],
)
result = app.acquire_token_for_client(scopes=["https://outlook.office365.com/.default"])
if "access_token" not in result:
    raise SystemExit(result.get("error_description"))

xoauth2 = f"user={SENDER}\x01auth=Bearer {result['access_token']}\x01\x01"

msg = EmailMessage()
msg["From"] = SENDER
msg["To"] = "someone@example.com"
msg["Subject"] = "Test from the app server"
msg.set_content("Sent through SMTP AUTH with OAuth.")

with smtplib.SMTP("smtp.office365.com", 587, timeout=30) as smtp:
    smtp.starttls()
    smtp.auth("XOAUTH2", lambda challenge=None: xoauth2)
    smtp.send_message(msg)
```

Keep one client object for the life of the process so tokens are reused until they expire, and load the secret from a file only the service user can read. Many mail libraries accept an access token directly, so check yours for XOAUTH2 support before writing this by hand. Postfix does not speak XOAUTH2 without a SASL plugin.

## Mail for your own staff: High Volume Email

HVE uses dedicated accounts that have no mailbox and need no license, on a separate endpoint, so application mail stays apart from people's mailboxes. HVE accounts sign in even when SMTP AUTH is disabled for the whole organization. They cannot deliver outside the tenant, and an account sends nothing until a billing policy is assigned to it.

Create the account under **Mail flow** > **High Volume Email** in the Exchange admin center, or with PowerShell:

```powershell
New-MailUser -HVEAccount -Name "alerts" -PrimarySmtpAddress "alerts@contoso.com"
Get-BillingPolicy -ResourceType HVE
Set-HVEAccountBillingPolicy -Identity "alerts@contoso.com" -BillingPolicyId "<policy-guid>"
```

If tools on the server hand mail to a local Postfix (cron output, monitoring, a PHP app using `sendmail`), let Postfix relay to HVE and listen only on the loopback interface. When the installer asks for the mail configuration type, choose **Satellite system**:

```bash
sudo apt install -y postfix libsasl2-modules
sudo postconf -e 'inet_interfaces = loopback-only' \
  'relayhost = [smtp.hve.mx.microsoft]:587' \
  'smtp_sasl_auth_enable = yes' \
  'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' \
  'smtp_sasl_security_options = noanonymous' \
  'smtp_tls_security_level = encrypt'
```

Put the credentials in `/etc/postfix/sasl_passwd` with an editor, so the password never lands in your shell history:

```text
[smtp.hve.mx.microsoft]:587 alerts@contoso.com:the-account-password
```

```bash
sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo systemctl restart postfix
```

Send with the HVE account's address as the sender, and rewrite local senders such as `root@hostname` to it with Postfix's `sender_canonical_maps`. Use OAuth instead of the password when your software supports it.

## Direct Send: the legacy route

Direct Send hands mail to your tenant's MX endpoint, such as `contoso-com.mail.protection.outlook.com`, on port 25 without signing in. Exchange treats it like any anonymous message from the internet, so it only reaches your own tenant and needs SPF that lists the server's IP, plus DKIM and DMARC set up correctly for the domain. Tenant admins can block it outright with `Set-OrganizationConfig -RejectDirectSend $true`, after which messages bounce with `550 5.7.68`, and Microsoft says it is working on an option to disable Direct Send by default. Use HVE for new internal mail instead.

On CloudSat, port 25 may be restricted on new accounts and is lifted on request, as explained in [Send email from your server](https://cloudsat.io/docs/sending-email). The restriction does not touch port 587, so SMTP AUTH and HVE work from the first day.

## Why the connector route is out

An inbound connector that trusts a certificate or a static IP looks like the cleanest option. Microsoft's documentation states that this SMTP relay method does not support mail from applications hosted by a third party and gives cloud hosting as the example. It is designed for devices on your own network. A rented VPS is a third-party host, so do not build on it, even if a test message gets through.

For external mail at volume, Microsoft points to Azure Communication Services Email. A transactional email provider reached on port 587 is another option, and so is running your own mail server, which our guide to [self-hosted mail server software](https://cloudsat.io/learn/self-hosted-mail-server-software-compared) compares.

## Test from the server first

Confirm the endpoint answers and offers the right sign-in methods. After the TLS handshake, type `EHLO test` and look for `XOAUTH2` in the `AUTH` line:

```bash
openssl s_client -connect smtp.office365.com:587 -starttls smtp -crlf -quiet
nc -vz -w 5 contoso-com.mail.protection.outlook.com 25
```

Then send a test message and read the delivered copy's headers: `Authentication-Results` should show `spf=pass`, `dkim=pass` and `dmarc=pass`. The errors you are most likely to meet:

| Reply | Usual cause |
| --- | --- |
| `535 5.7.3 Authentication unsuccessful` | Token or password refused: check admin consent, the object ID used for the service principal, the mailbox permission and SMTP AUTH on the mailbox |
| `5.7.60` | The account has no Send As permission for the sender address |
| `550 5.7.68` | Direct Send is rejected by the tenant's setting |
| Timeout on port 25 | Outbound port 25 is blocked by the network or host |

## FAQ

### Can my app keep using a mailbox password after December 2026?

Only if a tenant admin re-enables Basic auth for SMTP AUTH, and only until the final removal date Microsoft plans to announce in the second half of 2027. Plan the move to OAuth, or to HVE for internal mail, before the default changes.

### Can HVE send to customers?

No. HVE delivers only to recipients inside your own tenant. For customer mail, use SMTP AUTH within its limits, Azure Communication Services Email, a transactional provider, or your own mail server.

### Why does Direct Send mail land in junk?

It arrives unauthenticated, so Exchange filters it like any external message. SPF must list the server's IP, and DKIM and DMARC must pass for the sender's domain. HVE and SMTP AUTH avoid most of this for internal recipients.

### Which firewall ports does sending need?

Only outbound ones: 587 for SMTP AUTH and HVE, and 25 for Direct Send. Sending through Microsoft 365 needs no inbound port on your server.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Networking](https://cloudsat.io/learn/topic/networking-and-dns)

- [SMTP, IMAP and POP3 explained: ports, TLS and tests](https://cloudsat.io/learn/smtp-imap-and-pop3-explained): Networking SMTP, IMAP and POP3 explained: ports, TLS and tests 7 min read
- [Self-hosted mail server software: choosing a stack](https://cloudsat.io/learn/self-hosted-mail-server-software-compared): Self-hosting Self-hosted mail server software: choosing a stack 7 min read
- [Spam and malware filtering on your own mail server](https://cloudsat.io/learn/mail-server-spam-and-malware-filtering): Security Spam and malware filtering on your own mail server 7 min read
- [MikroTik DNS on RouterOS 7: caching, static records and DoH](https://cloudsat.io/learn/mikrotik-routeros-dns-setup): Networking MikroTik DNS on RouterOS 7: caching, static records and DoH 6 min read
