Moshe Raab
Moshe Raab

Reputation: 157

I started getting: Client not authenticated to send mail errors

I have written several C# apps that used the SmtpClient. they have been running for years. this week they all stopped working and are throwing the following exception:

System.Net.Mail.SmtpException
  HResult=0x80131500
  Message=The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator.   Source=System.Net.Mail

I am not a systems person, but a lowly programmer. I do manage my own Microsoft 365 account and Azure accounts.

in the c# app i am not using default credentials:

    using System.Net.Mail;
...
           client.Credentials = new System.Net.NetworkCredential(FROM, PW, DOMAIN);

In the MS 365 Admin Center when i select Authenticated SMTP i get the following error:

Cannot process argument transformation on parameter 'Identity'. Cannot convert value "" to type "Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter". Error: "Parameter values of type Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter can't be empty. Specify a value, and try again. Parameter name: identity"

when i exit my active user and enter it again, all the "Manage email apps" are checked. but i still get the error above and can't send email in my app.

what do i need to do to correct this?

Upvotes: 0

Views: 1841

Answers (2)

Moshe Raab
Moshe Raab

Reputation: 157

As Eugene pointed out, modern authentication is no longer supported. SO, i switched to using MailKit. but i still had to disable the TFA on my email account in order to use it, which i did not want to do. So instead, i created a new user with a long un-guessable(?) password to send the emails. it works fine now. thanks

Upvotes: 0

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

Basic authentication is now disabled in all Office365 tenants. Before December 31 2022, you could re-enable the affected protocols if users and apps in your tenant couldn't connect. Now no one (you or Microsoft support) can re-enable Basic authentication in your tenant. See Deprecation of Basic authentication in Exchange Online for more information.

System.Net.Mail doesn’t support modern authentication. Instead, you may consider using a third party SMTP client implementation such as MailKit.

Upvotes: 1

Related Questions