Authentication failed because the remote party has closed the transport stream

tuyen1644 21 Reputation points
2021-10-12T01:22:09.097+00:00

I have application auto daily send email using smtpclient, it's still running OK before 1-Oct-2021. But from 1-Oct-2021, it send missing email, i use try catch to debug this and get exception below:
139617-errorsendemail.jpg

Please, give me a solution other than having to set up TLS1.2 in the application.
Thanks!

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,198 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,870 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
505 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,333 questions
{count} votes

8 answers

Sort by: Most helpful
  1. Subhi Almohtasib 16 Reputation points
    2021-10-15T13:41:29+00:00

    Hello All,

    I was facing the same issue until I upgraded the .NET version to 4.6 instead of 4.5. Please refer to this answer here
    https://stackoverflow.com/a/45442874/9050439

    Hopefully it helps you.

    Thanks

    3 people found this answer helpful.

  2. Andy David - MVP 141K Reputation points MVP
    2021-10-12T13:58:07.23+00:00

    Is MFA required for this account? If so, that is expected.

    1 person found this answer helpful.

  3. Maxime Gagnon 6 Reputation points
    2021-10-14T21:32:58.633+00:00

    Same error here as well with an app developed for thousands of customers. We receive an unusual number of calls of very angry customers regarding this issue which is intermittent.

    Of course I can't ask my customers to simply use another email of different providers as they use the same address for numerous years now or use paid office365 accounts...

    I also made sure we use compatible version of TLS, and even with 1.1 or 1.2 , it doesn't always work.

    Clearly something's wrong with Microsoft SMTP servers...

    1 person found this answer helpful.

  4. Evan Knutson 6 Reputation points
    2021-10-14T21:47:06.507+00:00

    An update on my end. The issue is resolved. Forcing TLS1.2 was the fix. I upgraded from .NET 2... to .NET v4.0.30319 and set the below:

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12; 
            SmtpClient.TargetName = "STARTTLS/" + EmailServer; 
    

    I then had issues with registering the new .dll (i spoke incorrectly in my comment above). So when I thought the switch the TLS1.2 was not the fix, that was incorrect, the issue was that the .dll was not updating in the gac. I had to use an updated version of regasm.exe, found an updated version of gacutil.exe and also updated gacutil.exe.config.

    so for example I am using this to register:
    %windir%\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\Program Files (x86)[app directory here]\DNeMailer.dll" /tlb:"C:\Program Files (x86)[app directory here]\DNeMailer.tlb"

    And then to install into the gac. I had to update the version of .NET referenced in gacutil.exe.config.
    "C:\Program Files (x86)[app directory here]\gacutil.exe" /i "C:\Program Files (x86)[app directory here\DNeMailer.dll"

    It became obvious to me that the .dll was not updating when I was not able to uninstall the .dll from C:\Windows\assembly\

    1 person found this answer helpful.
    0 comments No comments

  5. AgaveJoe 26,181 Reputation points
    2021-10-12T16:55:58.7+00:00

    According to the MS 365 docs, deprecation of TLS 1.0 and 1.1 started in 2020. Also, according to the docs you can sent unencrypted SMTP which is not recommended though. The best approach is upgrading your systems/software to TLS 1.2.

    Preparing for TLS 1.2 in Office 365 and Office 365 GCC