Exchange Connection Problems

Fix Java SMTP 535 Authentication Failed with Office 365

Nimra MalikNimra Malik Nov 13, 2026 869 views

Question details

The user needs to resolve a JavaMail javax.mail.AuthenticationFailedException 535 5.7.3 error when sending email through smtp.office365.com.

Product
JavaMail / Microsoft 365 Exchange Online
Device & OS
not provided
Scenario
A Java application attempts to send mail through Outlook or Microsoft 365 but fails during SMTP authentication.
Observed behavior
The application throws javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful when connecting to smtp.office365.com.
Before you start

Confirm you can sign in to the affected mailbox at portal.office.com and that the account has an Exchange Online license. Also check whether your Microsoft 365 tenant allows SMTP AUTH, because many tenants disable basic authentication by default.

Solution 1Recommended

Enable SMTP AUTH and configure JavaMail for STARTTLS on port 587

Use this solution first to verify tenant and mailbox SMTP AUTH settings and apply the correct JavaMail connection properties.

The 535 5.7.3 error usually means authentication is rejected before mail is sent. Enabling Authenticated SMTP for the mailbox and sending credentials over a STARTTLS-secured connection on port 587 resolves most valid-credential failures.

1
Open the Microsoft 365 admin center

Sign in to admin.microsoft.com with an administrator account, then go to Users > Active users and select the mailbox that is failing.

2
Enable Authenticated SMTP for the mailbox

In the user pane, select Mail > Email apps, select Manage email apps, and turn on Authenticated SMTP. Save the change and wait a few minutes for it to apply.

3
Set the correct JavaMail properties

In the Java application, configure the session with mail.smtp.host=smtp.office365.com, mail.smtp.port=587, mail.smtp.auth=true, and mail.smtp.starttls.enable=true.

4
Use valid mailbox credentials

Set the SMTP username to the full email address of the licensed mailbox and use the current password or app password if required by the tenant policy.

Enable SMTP AUTH and configure JavaMail for STARTTLS on port 587
Expected result: The Java application should authenticate successfully and send mail without the 535 5.7.3 error when SMTP AUTH is enabled and these settings are used.
Free Microsoft Office alternative

WPS Office: A Free Microsoft Office Alternative for Document Work

WPS Office does not manage Microsoft 365 SMTP authentication, but it is a free, lightweight Microsoft Office alternative that opens, edits, and saves Word, Excel, PowerPoint, and PDF files with a familiar interface, making it easy to continue daily document work without Microsoft 365.

  1. 1. Download WPS Office: Go to the official WPS Office website and click Download WPS Office Free for your operating system.
  2. 2. Install and sign in: Run the installer, open WPS Office, and sign in or create a free WPS account to access cloud features.
  3. 3. Open existing Office files: Open Word, Excel, PowerPoint, or PDF files from your computer, email attachments, or cloud storage directly in WPS Office.
  4. 4. Continue editing and save in Microsoft-compatible formats: Edit documents normally and save them as .docx, .xlsx, .pptx, or PDF to maintain compatibility with Microsoft Office users.
Free to download and use for core document, spreadsheet, and presentation tasksCompatible with .docx, .xlsx, .pptx, and other Microsoft Office file formats used in email attachmentsFamiliar ribbon-style interface reduces the learning curve when moving from Microsoft OfficeLightweight and low-resource design works well on Windows, macOS, Linux, Android, and iOSBuilt-in PDF tools help you create and share documents without extra subscriptions
microsoft office alternative - wps office

Frequently Asked Questions

Why does JavaMail throw 535 5.7.3 with smtp.office365.com?

The 535 5.7.3 error means SMTP authentication was rejected. Common causes include incorrect credentials, SMTP AUTH disabled for the mailbox, basic authentication blocked by the Microsoft 365 tenant, or missing STARTTLS on port 587.

How do I enable SMTP AUTH for a Microsoft 365 mailbox?

Sign in to the Microsoft 365 admin center, go to Users > Active users, select the mailbox, open Mail > Email apps, and turn on Authenticated SMTP. Tenant-level settings and Exchange Online PowerShell can also control SMTP AUTH.

What are the correct Office 365 SMTP settings for JavaMail?

Use smtp.office365.com as the host, port 587, mail.smtp.auth=true, and mail.smtp.starttls.enable=true. Use the full email address as username and a valid password or OAuth 2.0 token as the password.

Can I still use basic authentication with Office 365 SMTP?

It depends on the tenant. Many Microsoft 365 tenants disable basic authentication for Exchange Online. If basic authentication is blocked, you should use OAuth 2.0 or an approved SMTP relay instead.

Does WPS Office include an SMTP email client?

No, WPS Office is a document, spreadsheet, presentation, and PDF editing suite. It does not provide an SMTP email client or manage Microsoft 365 SMTP authentication.