Afazal,
I'm not sure what you mean by app password vs. email password. Have you directly created a D365 user as opposed to importing a user from Active Directory, so that you're using Microsoft Single-Sign On? (More on this in a minute.)
In the D365 SMTP settings, the User/Password you provide should be the User/Password of the Office365 Email Account. This doesn't have to even be a (Office 365 User) that has a user in D365. This is the user that will be authenticating with the SMTP Server.
You could be using smtp.sendgrid.net, and a SendGrid user. It's the user allowed to authenticate in whoever is the SMTP service provider.
Please keep in mind, Microsoft is deprecating non-Active Directory users in March 2024. Best practice is to create D365 users via import from AD.
In any case, the SMTP Authentication credentials you provide - are those of the "email account". When it authenticates, it's trying to authenticate through Office365 - same as if you were to try to log into Outlook on the web.
In my example, I used my own email account - but it was just an example. This email account is MFA enabled. The only reason my test worked, is because I also "happen to be" logging into D365 as that same user - so, I passed MFA authentication when I logged into D365. That MFA-authenticated session was still active when I hit the test button.
IF...I had provided SMTP Authentication credentials for my MFA-enabled user, but then logged into D365 with some other account - when I hit the test button, it would have failed. Because...how is D365 going send a test email and then MFA-authenticate in that session? It can't.
The SMTP Authentication credentials you provide need to be for an account that is going to be able to successfully authenticate for anyone in D365 who may be sending an email, therefore - if you're going to use an Office365 mail account, it should not be MFA enabled. As I mentioned previously as well - Send As and Send on Behalf Of permissions will need to be provided for any accounts that may be sending an email from D365.
Understand that sending an email from D365 has a slightly different series of events than you sending from Outlook.
You sending an email from Outlook:
D365 sending an email email from D365:
- D365 User Sally@company.com posts a vendor payment, and the payment advice Print Management report specifies that it's delivered to the vendor as a PDF attachment in an email.
- An email FROM Sally@company.com is created, TO vendor@vendor.com.
- Even though the email is "from" the email address on Sally's account, D365 is sending it through the SMTP server - by authenticating as afazal@company.com - because that's the account you specified as the SMTP Server credentials.
- afazal@company.com should not be MFA-enabled, as there would be no way for Sally or D365 to pass MFA.
- Sally@company.com will need to have Send As / Send on Behalf Of enabled for afazal@company.com - so that Office365's mail server knows that it's ok for afazal to authenticate the SMTP server, with an email that is coming "from" someone else.