Fix Magento 2 SMTP Email Exception with Microsoft 365
Question details
Users experience a Laminas Mail SMTP RuntimeException in Magento 2 when attempting to send emails using Microsoft 365 or Outlook SMTP servers.

- Product
- Magento 2 / Microsoft 365
- Device & OS
- not provided
- Scenario
- Configuring a Magento 2 store to send transactional emails via Microsoft 365 or Outlook SMTP credentials.
- Observed behavior
- The system throws a Laminas Mail SMTP RuntimeException and fails to send the messages due to missing or mismatching sender addresses.
Ensure you have administrator access to your Magento 2 backend and verify that you have the exact login credentials for the Microsoft 365 or Outlook account being used for SMTP.
Match the 'From' Email Address with the SMTP Authentication Email
Resolve the Laminas Mail SMTP RuntimeException by ensuring the sender address in Magento exactly matches the authenticated Microsoft 365 account.
Microsoft 365 and Outlook SMTP servers enforce strict anti-spoofing policies. If the 'From' address on your outgoing email does not match the email address used to log into the SMTP server, the connection is rejected.
Log into your Magento 2 admin panel, navigate to 'Stores' > 'Settings' > 'Configuration', and expand the 'General' tab to select 'Store Email Addresses'.
Set the 'Sender Email' field (for General Contact, Sales Representative, etc.) to the exact Microsoft 365 email address you use for your SMTP authentication.
Go to 'Advanced' > 'System' (or navigate to your specific third-party SMTP module settings) and ensure 'SMTP Authentication' is enabled. Confirm the username is identical to the 'Sender Email' and the password is correct.
Click the 'Save Config' button, flush your Magento cache under 'System' > 'Cache Management', and send a test email to verify the exception is resolved.

Manage Your E-commerce Data with WPS Office
While troubleshooting backend server configurations like Magento SMTP requires specialized web tools, analyzing your e-commerce exports and sales reports is much easier with a reliable productivity suite. WPS Office is a free, lightweight, and highly compatible alternative to Microsoft Office, perfect for managing your business data.

Frequently Asked Questions
Why does Microsoft 365 reject my Magento 2 emails?
Microsoft 365 requires the 'From' address of the email to exactly match the email address used to authenticate the SMTP connection. If they mismatch, the server rejects the message to prevent email spoofing, throwing an SMTP exception.
What is a Laminas Mail SMTP RuntimeException?
This is an error thrown by the Laminas Mail framework, which is used by Magento 2.4 and newer versions. It occurs when the SMTP server refuses to process an outgoing email, most often due to authentication failures or missing sender headers.
How do I test my SMTP settings in Magento 2?
Most Magento 2 installations utilizing a third-party SMTP module include a 'Test Email' feature within the module's configuration settings. Enter a recipient email address and click the test button after updating your credentials to confirm the SMTP connection is successful.




