Fix Java SMTP 535 Authentication Failed with Office 365
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.
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.
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.
Sign in to admin.microsoft.com with an administrator account, then go to Users > Active users and select the mailbox that is failing.
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.
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.
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.

Use OAuth 2.0 when basic authentication is disabled
Use this solution if your Microsoft 365 tenant blocks basic authentication or requires modern authentication for SMTP.
Use an Exchange Online SMTP relay for devices or applications
Use this solution for line-of-business Java applications, printers, or servers that cannot support OAuth 2.0.
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. Download WPS Office: Go to the official WPS Office website and click Download WPS Office Free for your operating system.
- 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. Open existing Office files: Open Word, Excel, PowerPoint, or PDF files from your computer, email attachments, or cloud storage directly in WPS Office.
- 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.

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.




