SMTP Email Sending Configuration with Microsoft 365 (Azure)
Step-by-step technical guide to enable and configure authenticated SMTP relay (SMTP AUTH) in Exchange Online for laboratory applications.
1. Introduction
Sección titulada «1. Introducción»By default, Microsoft blocks basic SMTP authentication (SMTP AUTH) in modern tenants for security reasons (Security Defaults). For an external application (such as Redmine, WordPress, custom scripts, etc.) to be able to send automated emails using smtp.office365.com, explicit configuration in the Microsoft 365 and Exchange Online administration panels is required.
2. Prerequisites
Sección titulada «2. Requisitos Previos»- Access to the Microsoft 365 Admin Center with a Global Administrator or Exchange Administrator role.
- A dedicated user account with an active Exchange Online license (e.g.,
portel_user@portelcore.com). - Network outbound permitted from the local server to port 587 TCP (STARTTLS) externally.
3. Step 1: Enable Authenticated SMTP (SMTP AUTH)
Sección titulada «3. Paso 1: Habilitar SMTP Autenticado (SMTP AUTH)»This step resolves 90% of SMTP connection errors with Microsoft 365. Even if the account exists and is active, the SMTP Auth protocol must be enabled at the individual mailbox level:
- Sign in to the Microsoft 365 Admin Center.
- In the side menu, navigate to Users > Active users.
- Select the dedicated user (e.g.,
portel_user@portelcore.com). - In the right side panel, select the Mail tab.
- Under the Email applications section, click on Manage email applications.
- Check the Authenticated SMTP box.
- Select Save changes.
[!NOTE] Replicating this change across the distributed Exchange Online infrastructure may take 5 to 30 minutes to take full effect.
4. Step 2: Password and MFA Management (Entra ID)
Sección titulada «4. Paso 2: Gestión de Contraseñas y MFA (Entra ID)»Depending on the security policy implemented in your organization through Microsoft Entra ID, two scenarios are presented:
Scenario A: Multi-Factor Authentication (MFA) Enabled (Recommended)
Sección titulada «Escenario A: Autenticación Multifactor (MFA) Activada (Recomendado)»If the account has MFA mandatorily enabled by policies, the user's standard password will not work in basic SMTP applications. You must create an App password:
- Sign in with the SMTP account credentials on the My Account Security Info page.
- Click on Add method.
- In the drop-down menu, select App password.
- Assign it a descriptive name (e.g.,
Bouncer SMTP Portelcore). - Copy the generated 16-character app password (e.g.,
abcd-efgh-ijkl-mnop). - IMPORTANT: Use this generated key as the SMTP password in the client software, not the regular user password.
Scenario B: Conditional Policies and Exclusions
Sección titulada «Escenario B: Directivas condicionales y Exclusiones»If your organization has Security Defaults enabled in Entra ID, legacy SMTP authentication will be blocked globally. In this scenario, it is necessary to temporarily disable these defaults and replace them with specific Conditional Access Policies that allow SMTP Auth only to the static public IP of your servers.
5. Universal Configuration Parameters
Sección titulada «5. Parámetros de Configuración Universal»These are the values you must enter into the client software to establish the connection:
| Parameter | Standard Value | Technical Explanation |
|---|---|---|
| SMTP Server (Host) | smtp.office365.com | Microsoft 365 geo-distributed endpoint. |
| Port | 587 | Standard port for explicit TLS (STARTTLS). |
| Encryption / Security | STARTTLS | Secure negotiation initiated in plaintext that upgrades to a TLS channel. |
| Authentication | Login / Plain | Authentication methods supported by SMTP AUTH. |
| Username | portel_user@portelcore.com | Email account of the authenticated sender mailbox. |
| Password | [Contraseña de Aplicación] | Key generated in step 2 (Scenario A). |
| Sender (From) | portel_user@portelcore.com | Critical: Must match the user to avoid rejections due to Spoofing. |
6. Troubleshooting
Sección titulada «6. Resolución de Problemas (Troubleshooting)»535 5.7.3 Authentication unsuccessful
Sección titulada «535 5.7.3 Authentication unsuccessful»- Cause: Invalid credentials or active MFA preventing the use of the normal user password.
- Solution: Generate a new app password in the security portal and ensure it does not contain additional spaces.
5.7.57 Client not authenticated to send mail
Sección titulada «5.7.57 Client not authenticated to send mail»- Cause: The mailbox authenticates correctly, but the SMTP Auth policy is not allowed for this specific user.
- Solution: Repeat Step 1 and validate that the checkbox is active and saved in the Admin Center.
Connection Refused / TCP Timeout
Sección titulada «Connection Refused / TCP Timeout»- Cause: TCP outbound port 587 blocked by the local firewall (Proxmox/UFW) or the ISP.
- Solution: Check the network output from the server by running in the console:
Ventana de terminal nc -zv smtp.office365.com 587
⚡ Technical Success Checklist
Sección titulada «⚡ Checklist de Éxito Técnico»- ✓ Buzón Autorizado: SMTP AUTH habilitado explícitamente en las opciones de correo electrónico del usuario.
- ✓ Autenticación Bypass: Contraseña de aplicación de 16 caracteres generada y guardada de forma segura.
- ✓ Negociación STARTTLS: Servidor resolviendo
smtp.office365.comy saliendo por el puerto 587 de forma fluida.

