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.

Anonymous
2023-08-23T12:40:37+00:00

MY code
 string result = string.Empty;

                 var httpRequest = HttpContext.Current.Request;

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");

                mail.From = new MailAddress("******@amazeinc.in");

                mail.To.Add(EmailEntity.emailto);

                mail.Subject = EmailEntity.emailsubject;

                mail.Body = EmailEntity.emailbody;
 mail.IsBodyHtml = true;

                SmtpServer.Port = 587;

                SmtpServer.UseDefaultCredentials = false;

                SmtpServer.Credentials = new System.Net.NetworkCredential("******@amazeinc.in", "XXXXXXXXXXXXXXXX");

                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);

Outlook | Windows | Classic Outlook for Windows | For business

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2023-11-06T12:10:57+00:00

    Hi,

    I'm getting the same issue, it was about TLS versions, I solved it replacing :

                    SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");
    

    with

                    SmtpClient SmtpServer = new SmtpClient("smtp-legacy.office365.com");
    

    Can you try it and let us know ?

    FYI, I got that trick from :

    https://learn.microsoft.com/en-us/answers/questions/1164157/smtp-auth-modern-authentication-in-managed-devices

    Was this answer helpful?

    8 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-11-20T16:23:13+00:00

    I am using Direct Send option as described in the Mail Flow best practicesand it works like a charm.

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2023-09-12T07:05:27+00:00

    I'm getting the same error in a non-Azure / Active Directory Web Server ASP Net App, that was working at this time last year.

    "As suggested in another post"? what good is that? Bing sure isnt going to find it for me.

    I really am tired of MS answers that presume platform, or prior knowledge.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2023-08-23T15:59:38+00:00

    Hello Amaze E,

    I’m Segunfunmi, an Independent Advisor and Microsoft user like you. Thanks for posting the query here in this forum.

    The error message 535 5.7.139 Authentication unsuccessful indicates that the request did not meet the criteria to be authenticated successfully. This issue has several possible causes, including Azure Security Defaults and Conditional Access policy blocking Legacy Authentication1. You may want to check these settings to ensure they are not blocking your authentication attempts.

    Another possible solution is to use an App Password, which can be created by enabling/enforcing MFA for the user1. You can also try disabling MFA for the user or using “Authenticate an IMAP, POP or SMTP connection using OAuth,” as suggested in another post.

    If you have tried all of these solutions and are still experiencing issues, you may want to check the sign-in logs for the user in Azure Active Directory for more details. I hope this helps! Let me know if you have any further questions.

    Kind regards, Segunfunmi.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments