# MS365 Exchange Online SMTP OATH2 Error 501 5.5.4 Invalid Domain Name

**URL:** <https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [August 5, 2024, 10:46pm UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199 "2024-08-05T22:46:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnnie\_McCord](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@Johnnie\_McCord](https://forum.inductiveautomation.com/u/Johnnie_McCord)\
**Post date:** [August 5, 2024, 10:46pm UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199/1 "2024-08-05T22:46:22Z")

</div>

Hello all,

I am trying to set up email notifications using MS365/Exchange Online modern Auth (OAuth SMTP).

I have followed this guide on configuring the application on the Entra/Exchange side of things: [Authenticate an IMAP, POP or SMTP connection using OAuth | Microsoft Learn](https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth)

I followed this guide to set up the Ignition side of things: [New Features: OAuth2 Clients and OAuth SMTP Email Profiles](https://forum.inductiveautomation.com/t/new-features-oauth2-clients-and-oauth-smtp-email-profiles/66783)

Within Ignition OAuth2 Clients page, both the authorization and token test are successful. The returned permissions seem to match with what is expected.

However, when I attempt to send a test email I get Error: 501 5.5.4 Invalid Domain Name

Thinking it was the Exchange domain that was incorrect, I tried multiple domains that I found online and I was either unable to connect to the Exchange server or received the same error code. (ended back on [smtp.office365.com](http://smtp.office365.com))

Looking at the logs, the error seems to be in response to the EHLO message. Some additional searching revealed that this is generally due to a poorly formatted SMTP hostname send by the client (i.e. the name of the machine requesting to send an email, the Ignition gateway here). Or the hostname not being publicly resolvable by the Exchange server.

If that is the case, my question is what hostname does Ignition provide in the EHLO message?

Has anyone experienced a similar error?

Running Ignition 8.1.37 (b2024013011)

Thanks

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [August 6, 2024, 12:33am UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199/2 "2024-08-06T00:33:31Z")

</div>

my random notes, when I was in your shoe:

For email setting: follow this link, use option 1.

> **[How to set up a multifunction device or application to send emails using...](https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365)**
>
> Learn how to set up printers, scanners, LOB applications to send emails using Microsoft 365 or Office 365.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28a8b62029f49ee6b3f2da194fd1198802be3146.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/4/64079b119313448c40dea4dbf476d6258dec55cf.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f1657ceb375f4000133424c1b5c113654ec8a4b9.png)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Johnnie\_McCord](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@Johnnie\_McCord](https://forum.inductiveautomation.com/u/Johnnie_McCord)\
**Post date:** [August 6, 2024, 9:53pm UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199/3 "2024-08-06T21:53:19Z")

</div>

Thank you for the reply Eugene but that doesn't seem to work for me. I did confirm that the SMTP Auth was enabled for the user but I am still getting that same 501 5.5.4 Invalid Domain error.

---

<div class="post-metadata">

**Author:** ![jharrell](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jharrell](https://forum.inductiveautomation.com/u/jharrell)\
**Post date:** [March 13, 2026, 5:13pm UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199/4 "2026-03-13T17:13:39Z")

</div>

Did you ever determine the source of the hostname used for the EHLO?

If that is the case, my question is what hostname does Ignition provide in the EHLO message?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 13, 2026, 5:23pm UTC](https://forum.inductiveautomation.com/t/ms365-exchange-online-smtp-oath2-error-501-5-5-4-invalid-domain-name/94199/5 "2026-03-13T17:23:10Z")

</div>

> <https://github.com/javaee/javamail/blob/ae30c211710a384629584e9512777795435886fc/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java#L269-L308>

So whatever the result of `InetAddress.getLocalHost().getCanonicalHostName()` or `InetAddress.getLocalHost().getHostAddress()` is.

What issue are you having, and are you sure this is the problem?
