Skip to content

SMTP best practices

Bizzkit Mail dispatches every mail through the SMTP server you register as a mail provider. How you configure that server determines both the security of the connection and the deliverability of your mails. This page describes the configuration we expect customer solutions to use, and why.

You manage SMTP servers in the admin site under Settings → SMTP Servers. They can also be managed through the API — see the getting started guide and the Mail API reference.

Register your SMTP server with secure submission on port 587, STARTTLS encryption, and SMTP authentication.

Bizzkit recommends

  • Port: 587.
  • Authentication method: OAuth 2.0 client credentials if your mail provider supports it, for example Microsoft 365. Otherwise Basic, with the SMTP credentials issued by your mail provider. With both methods, Bizzkit Mail upgrades the connection to an encrypted one with STARTTLS before transmitting anything sensitive, and authenticates every submission.
SMTP server form with the recommended configuration
An SMTP server configured with the recommended settings

Why port 587 with STARTTLS

Port 587 is the standard message submission port, reserved for clients handing new mails over to a mail provider. Providers expect submissions on this port and typically require authentication on it, which is exactly the combination Bizzkit Mail uses: with the Basic and OAuth 2.0 client credentials authentication methods, Bizzkit Mail connects, upgrades the connection with STARTTLS, and then authenticates.

This matters for two reasons:

  • Confidentiality: STARTTLS encrypts the connection before your credentials and mail content are transmitted, so they never cross the network in plain text.
  • Deliverability: authenticated submission proves to your provider that the mail comes from your solution, which protects your sender reputation and prevents others from abusing your account.

Note that a server which does not offer STARTTLS on the configured port will fail dispatch — encryption is required, not opportunistic.

Ports to avoid

  • Port 25 is the relay port used for server-to-server mail transfer. It is typically unauthenticated, widely blocked for outbound traffic by cloud and network providers, and closely associated with spam filtering. Do not use it for submitting mails.
  • Port 465 expects the connection to be encrypted from the very first byte (implicit TLS). Bizzkit Mail only negotiates encryption with STARTTLS, so this port is not supported.

No authentication

Warning

With the authentication method None, Bizzkit Mail skips SMTP authentication, and it encrypts the connection only if the server offers STARTTLS. Only use it for isolated test setups or internal relays that are unreachable from the outside — never in production.

Connection timeout

The Connection timeout controls how long Bizzkit Mail waits for a reply from your SMTP server, and defaults to 3000 milliseconds when omitted. If your provider is occasionally slow to respond, raise it — for example to 10000 milliseconds — since a timeout that is too low results in failed dispatch attempts. The maximum is 60000 milliseconds.

Microsoft 365

To send mails through Microsoft 365, use the OAuth 2.0 client credentials authentication method. Bizzkit Mail then signs in as an app registration in Microsoft Entra, and the app sends the mails from a mailbox in Exchange Online.

You need:

  • A Microsoft Entra role that can register apps and grant admin consent, for example Global Administrator.
  • An Exchange Online administrator role, and the Exchange Online PowerShell module.
  • The mailbox that sends the mails, for example noreply@example.com.

The steps below follow the Microsoft guide Authenticate an IMAP, POP or SMTP connection using OAuth. The names of the menus in the Microsoft portals can change. Check the Microsoft guide if a step does not match what you see.

Register an app

  1. In the Microsoft Entra admin center, go to App registrations, and select New registration.
  2. Enter a name, for example Bizzkit Mail. Select that only accounts in your organizational directory can use the app (single tenant), and select Register.
  3. On the Overview page of the app, copy the Application (client) ID and the Directory (tenant) ID.

Give the app permission to send with SMTP

  1. On the app, go to API permissions, and select Add a permission.
  2. Select APIs my organization uses, and search for Office 365 Exchange Online.
  3. Select Application permissions, select SMTP.SendAsApp, and select Add permissions.
  4. Select Grant admin consent for your organization. The status of SMTP.SendAsApp must change to granted.

Create a client secret

  1. On the app, go to Certificates & secrets, and select New client secret.
  2. Enter a description, select when the secret expires, and select Add.
  3. Copy the Value of the secret at once. Microsoft shows it only one time. Do not copy the Secret ID: it is not the secret, and the token request fails with it.
  4. Note the Expires date of the secret. You enter it in Bizzkit Mail.

Register the service principal

Exchange Online needs its own service principal for the app before you can give the app access to a mailbox.

  1. In the Microsoft Entra admin center, go to Enterprise applications, and open the app. Copy its Object ID. Use the object ID of the enterprise application, not the object ID on the App registrations page.
  2. Connect to Exchange Online PowerShell, and create the service principal. Replace the values in angle brackets:

    Connect-ExchangeOnline -Organization <tenant ID>
    New-ServicePrincipal -AppId <client ID> -ObjectId <object ID>
    

Give the app access to the mailbox

  1. Give the service principal access to the mailbox that sends the mails:

    Add-MailboxPermission -Identity "noreply@example.com" -User <object ID> -AccessRights FullAccess
    
  2. If your mails use a From address of another mailbox, also give the service principal permission to send as that address:

    Add-RecipientPermission -Identity "orders@example.com" -Trustee <object ID> -AccessRights SendAs
    

Exchange Online rejects a mail with a From address that the app may not send as. The mailbox in the Username field can always send as its own address.

Turn on SMTP AUTH for the mailbox

Exchange Online accepts SMTP AUTH only for mailboxes that allow it. Turn it on for the mailbox:

Set-CASMailbox -Identity "noreply@example.com" -SmtpClientAuthenticationDisabled $false

You can also turn it on in the Microsoft 365 admin center: open the user in Active users, select Mail → Manage email apps, and select Authenticated SMTP. The setting on the mailbox overrides the setting for the whole organization.

Set up the SMTP server

  1. In Bizzkit Mail, go to Settings → SMTP Servers, and create an SMTP server with these values:
    • Host-address: smtp.office365.com.
    • Port: 587.
    • Authentication method: OAuth 2.0 client credentials.
    • Provider: Microsoft 365.
    • Tenant ID: the directory (tenant) ID of the app.
    • Client ID: the application (client) ID of the app.
    • Client secret: the value of the client secret.
    • Username: the mailbox, for example noreply@example.com.
    • Secret expiry date: the expiry date of the client secret.
    • Active: selected.
  2. Open the SMTP server again, and select Test connection. The latest authentication check must succeed. See Authentication health for what a failed check means.
  3. Open a mail policy that uses the SMTP server, and select Send test email. Use a From address that your mails use. Then check the status of the test email in Mails. See Send test email.

Changes in Microsoft 365 can take some time before they take effect. If a test fails right after you change a permission, wait a while and try again.

Bizzkit recommends

Create a mailbox only for the mails from your solution, for example noreply@example.com, and give the app access to that mailbox only. The SMTP.SendAsApp permission lets the app send from every mailbox that the service principal has access to, so this keeps the client secret from being used for other mailboxes.

Enter the correct Secret expiry date. Bizzkit Mail warns you 30 days before the client secret expires, so you can create a new secret and save it in Bizzkit Mail before mails stop.