Share via

Cannot send email through Office 365 using SMTP server

Anonymous
2021-04-08T14:51:38+00:00

A client of mine recently changed IT providers, and in doing so, recreated their Office 365 setup (including Sharepoint and Outlook).

When they did this, they turned on MFA (multi-factor authentication) as default. In doing this, it seems they have somehow blocked my application from sending emails through the SMTP server under their users.

Here is the basic sample of my code

using (SmtpClient client = new SmtpClient("Smtp.office365.com", 587))

{

    client.EnableSsl = true;

    client.UseDefaultCredentials = false;

    client.Credentials = new NetworkCredential("******@domain.com", "password");

    MailMessage mail = new MailMessage()

    {

        From = new MailAddress("******@domain.com"),

        IsBodyHtml = false,

        Subject = "Test message",

        Body = "Test content",

    };

    mail.To.Add(new MailAddress("******@domain.com"));

    client.Send(mail);

};

When I send an email I receive the following error -

System.Net.Mail.SmtpException: '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.

So at first I was unable to send due to MFA being turned ON, but now I don't think that's the problem anymore, we've tried a lot of stuff, and I still can't get an email to send.

I can log in to the account using the username/password I've been given, so I don't believe it's a true authentication problem.

Here's what we've tried:

  • Enabling SMTP auth
  • App passwords instead of user password to circumvent the MFA in the app.
  • Disabling MFA on this particular user.
  • Switching this account from a shared mailbox to a regular mailbox.
  • Disabling Azure Security Defaults.

I don't know what else to look at. The error doesn't seem to be pointing to anything obvious. Can someone please help.

Thanks,

Chris

Outlook | Windows | Classic Outlook for Windows | For home

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

16 answers

Sort by: Most helpful
  1. Anonymous
    2021-04-19T20:27:05+00:00

    Hey chris84948

    The problem is solved and I'm able to now use emails, it was a new feature on Azure you need to tweak, sending you a screen shot.

    Let me know if it solves your issue.

    Was this answer helpful?

    4 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2021-04-21T14:59:26+00:00

    Thanks for the info. This is what we ended up doing too.

    I think we ended up doing it per-user?

    The other advice they gave us what that SMTP access would probably shut down in the next year, so we might have to switch to Graph API? Not sure about that one yet though.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2021-04-08T20:32:27+00:00

    Hello Chris,

    Many thanks for posting back.

    We have discuss this case with our senior and seems your application doesn’t support this client submission method. So they suggest you to kindly try to change the method and use SMTP relay to check if it works.

    For detail step by step configuration, please check our official article for Configure a connector to send mail using Microsoft 365 or Office 365 SMTP relay.

    Thanking you.

    Regards,

    Ankita Vaidya

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2021-04-08T18:48:04+00:00

    Thanks for the response.

    I tested on port 25, and there was no difference.

    If I understand things correctly (and I may not), I believe TLS/StartTLS is just another name for SSL, and I have enabled SSL. All of those settings are the same as when they worked on the previous o365 account, where there was no MFA on any accounts.

    I've tried this on two different accounts, with the same settings, and I'm getting the same response. I'm not 100% sure I know what you mean about removing the account from my app settings? It's just a user/password on my end now. I've simplified it as much as possible.

    Thanks.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2021-04-08T18:31:16+00:00

    Hello Chris,

    Thanks for your post in Microsoft community.

    Just received your case and first of all we appreciate your troubleshoot skill and thank you very much for providing breif information for your entire issue and SMTP client settings.

    Based on our official article for SMTP AUTH client submission method, we are using two ports 587 or 25, so based on this information would like to confirm have you tried to change your port settings with port 25? If not, request you to please kindly change your port setting and set as 25 to see if it makes any difference.

    Further for SMTP AUTH client submission, TLS/StartTLS are required, so please change this settings from your application side and check the effect. Also kindly verify that the application is able to negotiate TLS, as TLS is required in order to authenticate. For more information, please kindly see How to set up a multifunction device or application to send email using SMTP AUTH client submission.

    You may try to remove the affected account from your application settings and add it again to check the impact.

    For your reference, here sharing our official article for the error code 5.7.57 issue Fix issues with SMTP client submission, please kindly check it.

    Thank you so much for your precious time.

    Regards,

    Ankita Vaidya

    Was this answer helpful?

    0 comments No comments