SmtpException: Unable to read data from the transport connection: net_io_connectionclosed
Asked Answered
A

37

153

I am using the SmtpClient library to send emails using the following:

SmtpClient client = new SmtpClient();
client.Host = "hostname";
client.Port = 465;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("User", "Pass);
client.Send("from@hostname", "to@hostname", "Subject", "Body");

The code works fine in my test environment, but when I use production SMTP servers, the code fails with an SmtpException "Failure sending mail." with an inner IOException "Unable to read data from the transport connection: net_io_connectionclosed".

I've confirmed that firewalls are not an issue. The port opens just fine between the client and the server. I'm not sure what else could throw this error.

Augie answered 26/11, 2013 at 21:47 Comment(1)
Just in-case anyone digs up this post, I had the same problems, (Unable to read data from the transport connection: net_io_connectionclosed.), but I was using 587. I had to update our app from 3.5 .net to 4.8. The new libraries did the trick for me.Ichor
A
242

EDIT: Super Redux Version

Try port 587 instead of 465. Port 465 is technically deprecated.


After a bunch of packet sniffing I figured it out. First, here's the short answer:

The .NET SmtpClient only supports encryption via STARTTLS. If the EnableSsl flag is set, the server must respond to EHLO with a STARTTLS, otherwise it will throw an exception. See the MSDN documentation for more details.

Second, a quick SMTP history lesson for those who stumble upon this problem in the future:

Back in the day, when services wanted to also offer encryption they were assigned a different port number, and on that port number they immediately initiated an SSL connection. As time went on they realized it was silly to waste two port numbers for one service and they devised a way for services to allow plaintext and encryption on the same port using STARTTLS. Communication would start using plaintext, then use the STARTTLS command to upgrade to an encrypted connection. STARTTLS became the standard for SMTP encryption. Unfortunately, as it always happens when a new standard is implemented, there is a hodgepodge of compatibility with all the clients and servers out there.

In my case, my user was trying to connect the software to a server that was forcing an immediate SSL connection, which is the legacy method that is not supported by Microsoft in .NET.

Augie answered 27/11, 2013 at 20:57 Comment(7)
how can I tell if the Server that I'm connecting with has the same issues? I'm trying to use SmtpClient with yahoo and/or gmail and get the described error. When I try against an 2013 exchange server, my code works fine.Wentzel
The most simple way to test is to try using port 587 and not 465. While some SMTP servers support TLS on 465 (and sometimes even 25), only port 587 is required to support TLS. In addition to that, use of port 465 has been deprecated since 1998 (en.wikipedia.org/wiki/SMTPS), although in practice many servers have it enabled for legacy clients.Augie
Yes, changing to 587 did the trick. Thanks for pointing me in the right direction.Wentzel
587 works although smtp.att.yahaoo.com says use 465. Thanks man.Safier
For an actual solution, see https://mcmap.net/q/159892/-how-can-i-send-emails-through-ssl-smtp-with-the-net-framework on using the (deprecated) System.Web.Mail which does support implicit SSL.Twinge
It works for me, using this #17228032Bondswoman
and long version ? not reduxJeweljeweler
J
61

Putting this at the beginning of my method fixed this for me

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
Judah answered 7/2, 2022 at 12:30 Comment(8)
This seems to be the correct answer in 2022. I also added some other Protocols> ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;Ruffled
tested the other answers, but only this one worked for meGoldagoldarina
Yeah, since Jan 22 2022, Google has increased the TLS version requirements, so for Gmail SMTP, you have to use this code if you want to use Google SMTP service.Cardiac
Office 365 (smtp.office365.com) has also started requiring TLS 1.2. If you target a version of .NET Framework less than 4.7, you should set SecurityProtocol to Tls12 | Tls13. If you can target .NET 4.7 or later, then use the new SecurityProtocolType.SystemDefault instead so it will use the OS's preferred TLS level. See .NET 4.7's Release Notes and Transport Layer Security (TLS) best practices with the .NET Framework.Ostensorium
We should add all possible TLS protocols to make it work. This was helped me to solve my issue.Union
Using office365 from MS Azure Web Application -- Added this code right above client.send() and it worked as well.Orazio
Only way to get it to work on Office365! Awesome work, I'll buy you a beer if we ever meet in real life!Eldridgeeldritch
Only thing that worked for me when my app worked on all servers apart from Server 2008 (yes it's 2023 but it's a customer server). I'd love to know how @simon Fallai got this answer.Euonymus
M
29

For anyone who stumbles across this post looking for a solution and you've set up SMTP sendgrid via Azure.

The username is not the username you set up when you've created the sendgrid object in azure. To find your username;

  • Click on your sendgrid object in azure and click manage. You will be redirected to the SendGrid site.
  • Confirm your email and then copy down the username displayed there.. it's an automatically generated username.
  • Add the username from SendGrid into your SMTP settings in the web.config file.

Hope this helps!

Measures answered 28/9, 2016 at 2:26 Comment(3)
This might seem silly but something else that you might want to check is if the password is correct for the SMTP SendGrid setup. Our setup was originally working and then one day we started getting the OP's exception message. Searches on the WWW mostly pointed to looking at other SMTP Server configurations when eventually it turned out the password was incorrect. Someone in the team had changed the password in the configuration file to a variation where the first letter was non-capitalised.Smiley
In my case the user name was incorrect and had a typo. But a wrong password can also give the "Unable to read data from the transport connection: net_io_connectionclosed." error. So check both the username and password. And for Azure users, the user name is of the form "[email protected]" (eg: [email protected])Armistice
this worked for me. Though I was using port 587 since the start.Lawrencelawrencium
O
23

Change the port from 465 to 587 and it should work.

Originality answered 16/1, 2016 at 14:17 Comment(1)
I'm not sure what happened but this works me using gmail smtp. can you explain why this works?Guppy
W
13

I've tried all the answers above but still get this error with Office 365 account. The code seems to work fine with Google account and smtp.gmail.com when allowing less secure apps.

Any other suggestions that I could try?

Here is the code that I'm using

int port = 587;
string host = "smtp.office365.com";
string username = "[email protected]";
string password = "password";
string mailFrom = "[email protected]";
string mailTo = "[email protected]";
string mailTitle = "Testtitle";
string mailMessage = "Testmessage";

using (SmtpClient client = new SmtpClient())
{
    MailAddress from = new MailAddress(mailFrom);
    MailMessage message = new MailMessage
    {
        From = from
    };
    message.To.Add(mailTo);
    message.Subject = mailTitle;
    message.Body = mailMessage;
    message.IsBodyHtml = true;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Host = host;
    client.Port = port;
    client.EnableSsl = true;
    client.Credentials = new NetworkCredential
    {
        UserName = username,
        Password = password
    }; 
    client.Send(message);
}

UPDATE AND HOW I SOLVED IT:

Solved problem by changing Smtp Client to Mailkit. The System.Net.Mail Smtp Client is now not recommended to use by Microsoft because of security issues and you should instead be using MailKit. Using Mailkit gave me clearer error messages that I could understand finding the root cause of the problem (license issue). You can get Mailkit by downloading it as a Nuget Package.

Read documentation about Smtp Client for more information: https://learn.microsoft.com/es-es/dotnet/api/system.net.mail.smtpclient?redirectedfrom=MSDN&view=netframework-4.7.2

Here is how I implemented SmtpClient with MailKit

        int port = 587;
        string host = "smtp.office365.com";
        string username = "[email protected]";
        string password = "password";
        string mailFrom = "[email protected]";
        string mailTo = "[email protected]";
        string mailTitle = "Testtitle";
        string mailMessage = "Testmessage";

        var message = new MimeMessage();
        message.From.Add(new MailboxAddress(mailFrom));
        message.To.Add(new MailboxAddress(mailTo));
        message.Subject = mailTitle;
        message.Body = new TextPart("plain") { Text = mailMessage };

        using (var client = new SmtpClient())
        {
            client.Connect(host , port, SecureSocketOptions.StartTls);
            client.Authenticate(username, password);

            client.Send(message);
            client.Disconnect(true);
        }
Waldron answered 2/11, 2018 at 10:15 Comment(1)
If you get the "The SMTP server has unexpectedly disconnected." It might be that your provider doesn't have TLS. Even though my provider says TLS compatible, it didn't work so I tried with SecureSocketOptions.SslOnConnect and got it to work. If it can help someone.Diaconate
C
11

You may also have to change the "less secure apps" setting on your Gmail account. EnableSsl, use port 587 and enable "less secure apps". If you google the less secure apps part there are google help pages that will link you right to the page for your account. That was my problem but everything is working now thanks to all the answers above.

Cardboard answered 18/3, 2016 at 4:8 Comment(4)
Thanks Bill. This still works with my standard gmail account. If you don't use the "less secure apps" setting, you have to use OAuth2 2-part authentication. This is not practical when you just want to send confirmation email from a website.Dee
Where is the "less secure apps" settting. I'm in my gmail account looking for it.Emaciated
I located the "Less Secure Apps" setting - it's not in the Gmail Settings, but in the Google Account Settings: My Account > Sign-in and Security myaccount.google.com/…Ostracoderm
100 points to Google, who has since disabled the "Less Secure Apps" setting on my account. Guess it's time to upgrade our app! :)Prolepsis
H
8

Answer Specific to Outlook Mailer

var SmtpClient = new SmtpClient{
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials = new System.Net.NetworkCredential("email", "password"),
                Port = 587,
                Host = "smtp.office365.com",
                EnableSsl = true }

https://admin.exchange.microsoft.com/#/settings -> Click on Mail Flow

-> Check - Turn on use of legacy TLS clients

-> Save

enter image description here

Hockett answered 24/1, 2022 at 23:14 Comment(0)
V
5

removing

client.UseDefaultCredentials = false; 

seemed to solve it for me.

Vicechancellor answered 25/10, 2019 at 1:54 Comment(0)
M
4

First Use Port = 587

Generally STARTTLS is required to send mail, Adding the Security Protocol Tls12 will help to resolve this issue.

Secondly test the stmp connection using powershell

$userName = 'username_here'
$password = 'xxxxxxxxx'
$pwdSecureString = ConvertTo-SecureString -Force -AsPlainText $password
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $pwdSecureString

$sendMailParams = @{
    From = 'abc.com'
    To = '[email protected]'
    Subject = 'Test SMTP'
    Body = 'Test SMTP'
    SMTPServer = 'smtp.server.com'
    Port = 587
    UseSsl = $true
    Credential = $credential
}

Send-MailMessage @sendMailParams

Thirdly If this send out the email, Add below code inside SmtpClient function:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;                            
Milford answered 25/6, 2022 at 15:40 Comment(1)
This looks like you copy/pasted another answer (which you wrote) from here: How to resolve Unable to read data from the transport connection: net_io_connectionclosed error while sending email using SMTPClient. Instead of doing that, if the questions are the same then it is better to flag one as a duplicate of the other. If the questions are not the same then the answers should probably not be identical to each other.Unknot
S
3

Does your SMTP library supports encrypted connection ? The mail server might be expecting secure TLS connection and hence closing the connection in absence of a TLS handshake

Shurlock answered 26/11, 2013 at 21:52 Comment(1)
It is just the default .NET SmtpClient library, it does support encrytpion, the server does require encryption, and I have set client.EnableSssl = true;. Although I think I'm going to persue this a little further with Wireshark.Augie
E
3

If you are using an SMTP server on the same box and your SMTP is bound to an IP address instead of "Any Assigned" it may fail because it is trying to use an IP address (like 127.0.0.1) that SMTP is not currently working on.

Elevator answered 7/7, 2016 at 16:46 Comment(0)
T
3

Since Jan 22 2022, Google has increased the TLS version requirements Also Microsoft has revoked the support for TLS 1.0 and TLS 1.1 for the earlier versions of the .NET framework than 4.6.

So we can fix the issue one of the below 2 solutions.

1.By Adding some other Protocols before creating the smtp client >> ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

2.You just need to update the .NET framework version to 4.6 or higher to fix the issue.

Tempt answered 10/10, 2022 at 13:45 Comment(0)
A
2

To elevate what jocull mentioned in a comment, I was doing everything mention in this thread and striking out... because mine was in a loop to be run over and over; after the first time through the loop, it would sometimes fail. Always worked the first time through the loop.

To be clear: the loop includes the creation of SmtpClient, and then doing .Send with the right data. The SmtpClient was created inside a try/catch block, to catch errors and to be sure the object got destroyed before the bottom of the loop.

In my case, the solution was to make sure that SmtpClient was disposed after each time in the loop (either via using() statement or by doing a manual dispose). Even if the SmtpClient object is being implicitly destroyed in the loop, .NET appears to be leaving stuff lying around to conflict with the next attempt.

Aqualung answered 20/8, 2018 at 18:50 Comment(0)
K
2

Change your port number to 587 from 465

Kinky answered 19/6, 2019 at 9:27 Comment(0)
S
2

I got the same problem with the .NET smtp client + office 365 mail server: sometimes mails were sent successfully, sometimes not (intermittent sending failures).

The problem was fixed by setting the desired TLS version to 1.2 only. The original code (which started to fail in the middle of the year 2021 - BTW) was allowing TLS 1.0, TLS 1.1 and TLS 1.2.

Code (CLI/C++)

    int tls12 = 3072; // Tls12 is not defined in the SecurityProtocolType enum in CLI/C++ / ToolsVersion="4.0"  
    System::Net::ServicePointManager::SecurityProtocol = (SecurityProtocolType) tls12;

(note: the problem was reproduced and fixed on a Win 8.1 machine)

Stockton answered 6/2, 2022 at 12:24 Comment(0)
F
1

In my case, the customer forgot to add new IP address in their SMTP settings. Open IIS 6.0 in the server which sets up the smtp, right click Smtp virtual server, choose Properties, Access tab, click Connections, add IP address of the new server. Then click Relay, also add IP address of the new server. This solved my issue.

Familiar answered 11/1, 2019 at 2:18 Comment(0)
C
1

If your mail server is Gmail (smtp.google.com), you will get this error when you hit the message limit. Gmail allows sending over SMTP up to only 2000 messages per 24 hours.

Causeway answered 17/12, 2019 at 19:54 Comment(0)
H
1

I ran into this when using smtp.office365.com, using port 587 with SSL. I was able to log in to the account using portal.office.com and I could confirm the account had a license. But when I fired the code to send emails, I kept getting the net_io_connectionclosed error.

Took me some time to figure it out, but the Exchange admin found the culprit. We're using O365 but the Exchange server was in a hybrid environment. Although the account we were trying to use was synced to Azure AD and had a valid O365 license, for some reason the mailbox was still residing on the hybrid Exchange server - not Exchange online. After the exchange admin used the "Move-Mailbox" command to move the mailbox from the hybrid exchange server to O365 we could use the code to send emails using o365.

Heat answered 10/6, 2020 at 12:13 Comment(0)
D
1

If you are using Sendgrid and if you receive this error, it is because Basic authentication is no more allowed by sendgrid.We need to create API key and use them as NetworkCredential. username="apikey" password will be your API key Reference - https://docs.sendgrid.com/for-developers/sending-email/integrating-with-the-smtp-api

Diamagnetism answered 29/6, 2021 at 8:44 Comment(0)
E
1

I recently had to set new mail settings on all our applications and encountered this error on multiple projects.

The solution for me was to update the target framework to a newer version on some of my projects.

I also had an ASP.net website project where updating the target framework wasn't enough I also had to add the following code to the web.config <httpRuntime targetFramework="4.8"/>

Ewold answered 16/2, 2022 at 17:4 Comment(0)
S
1

After trying all sorts of TLS/SSL/port/etc things, for me the issue was this: the username and password I was using for Credentials were not correct, apparently.

Normally our websites use a different set of credentials but this one's were different. I had assumed they were correct but apparently not.

So I'd double check my credentials if nothing else is working for you. What a precise error message!

Synoptic answered 2/2, 2023 at 17:43 Comment(0)
A
0

Try this : Here is the code which i'm using to send emails to multiple user.

 public string gmail_send()
    {
        using (MailMessage mailMessage =
        new MailMessage(new MailAddress(toemail),
    new MailAddress(toemail)))
        {
            mailMessage.Body = body;
            mailMessage.Subject = subject;
            try
            {
                SmtpClient SmtpServer = new SmtpClient();
                SmtpServer.Credentials =
                    new System.Net.NetworkCredential(email, password);
                SmtpServer.Port = 587;
                SmtpServer.Host = "smtp.gmail.com";
                SmtpServer.EnableSsl = true;
                mail = new MailMessage();
                String[] addr = toemail.Split(','); // toemail is a string which contains many email address separated by comma
                mail.From = new MailAddress(email);
                Byte i;
                for (i = 0; i < addr.Length; i++)
                    mail.To.Add(addr[i]);
                mail.Subject = subject;
                mail.Body = body;
                mail.IsBodyHtml = true;
                mail.DeliveryNotificationOptions =
                    DeliveryNotificationOptions.OnFailure;
                //   mail.ReplyTo = new MailAddress(toemail);
                mail.ReplyToList.Add(toemail);
                SmtpServer.Send(mail);
                return "Mail Sent";
            }
            catch (Exception ex)
            {
                string exp = ex.ToString();
                return "Mail Not Sent ... and ther error is " + exp;
            }
        }
    }
Amanda answered 27/11, 2013 at 4:24 Comment(1)
SmtpClient is also Disposable, so it should be wrapped in a using blockDeva
O
0

In case if all above solutions don't work for you then try to update following file to your server (by publish i mean, and a build before that would be helpful).

bin-> projectname.dll 

After updating you will see this error. as i have solved with this solution.

Opiumism answered 23/4, 2017 at 22:14 Comment(2)
Amazingly this worked for me! Allow insecure apps was on and port was set to 587 already.Flyman
Thanks, just realized i was not the only one with this issue. happy to help.Opiumism
T
0

For outlook use following setting that is not giving error to me

SMTP server name smtp-mail.outlook.com

SMTP port 587

Tweak answered 23/9, 2018 at 18:57 Comment(0)
R
0

This error is very generic .It can be due to many reason such as The mail server is incorrect. Some hosting company uses mail.domainname format. If you just use domain name it will not work. check credentials host name username password if needed Check with hosting company.

<smtp from="[email protected]">
        <!-- Uncomment to specify SMTP settings -->
        <network host="domain.com" port="25" password="Jin@" userName="[email protected]"/>
      </smtp>
    </mailSettings>
Rodman answered 3/12, 2018 at 19:50 Comment(0)
E
0

In my case the web server IP was blocked on the mail server, it needs to be unblocked by your hosting company and make it whitelisted. Also, use port port 587.

Enochenol answered 30/11, 2019 at 11:20 Comment(0)
P
0

My original problem is about intermittent sending failures. E.g. First Send() succeeds, 2nd Send() fails, 3rd Send() succeeds. Initially I thought I wasn't disposing properly. So I resorted to using().

Anyways, later I added the UseDefaultCredentials = false, and the Send() finally became stable. Not sure why though.

Pericline answered 1/2, 2021 at 9:53 Comment(0)
T
0

SmtpException: Unable to read data from the transport connection: net_io_connectionclosed

There are two solutions. First solution is for app level (deployment required) and second one is for machine level (especially if you use an out-of-the-box / off-the-shelf app)

When we checked the exception, we saw that the protocol is "ssl|tls" depriciated pair.

Since we don't want to deploy, we prefer machine level change (Solution 2).

On August 18, Microsoft announced that they will disable Transport Layer Security (TLS) 1.0 and 1.1 connections to Exchange Online “in 2022.” https://office365itpros.com/2021/08/19/exchange-online-to-introduce-legacy-smtp-endpoint-in-2022/

Firstly let's check the network (Anything prevents your email sent request? firewall, IDS, etc.)

By using PowerShell check Transport Layer Security protocols

[Net.ServicePointManager]::SecurityProtocol

My Output: Tls, Tls11, Tls12

Test SMTP Authentication over TLS

$HostName = [System.Net.DNS]::GetHostByName($Null).HostName
$Message = new-object Net.Mail.MailMessage 
$smtp = new-object Net.Mail.SmtpClient("smtp.office365.com", 587) 
$smtp.Credentials = New-Object System.Net.NetworkCredential("[email protected]", "PassMeme"); 
$smtp.EnableSsl = $true 
$smtp.Timeout = 400000  
$Message.From = "[email protected]" 
$Message.Subject = $HostName + " PowerShell Email Test"
$Message.Body = "Email Body Message"
$Message.To.Add("[email protected]") 
#$Message.Attachments.Add("C:\foo\attach.txt") 
$smtp.Send($Message)

My output: There is no error message If there is any message on your output something prevents your email sent request.

If everything is ok there should be two solutions.

Solution 1:

Application Level TLS 1.2 Configuration (Optional) Application deployment required.

Explicitly choose TLS in C# or VB code:

ServicePointManager.SecurityProtocol |=  SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12

Solution 2:

Machine level TLS 1.2 .NET Framework configuration Application deployment NOT required.

Set the SchUseStrongCrypto registry setting to DWORD:00000001. You should restart the server.

For 32-bit applications on 32-bit systems or 64-bit applications on 64-bit systems), update the following subkey value:

HKEY_LOCAL_MACHINE\SOFTWARE\
   \Microsoft\.NETFramework\\<version>
      SchUseStrongCrypto = (DWORD): 00000001

For 32-bit applications that are running on x64-based systems, update the following subkey value:

HKEY_LOCAL_MACHINE\SOFTWARE\
    Wow6432Node\Microsoft\\.NETFramework\\<version>
       SchUseStrongCrypto = (DWORD): 00000001

For details "How to enable TLS 1.2 on clients" on https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/security/enable-tls-1-2-client

Tenorio answered 18/3, 2022 at 16:19 Comment(0)
I
0

Our email service is Azure SendGrid. Our application stopped sending emails one day, and the error message was "SmtpException: Unable to receive data from the transport connection: net io connectionclosed." We discovered the problem was caused by the fact that our Pro 300K subscription had run out. Emails began to be sent when we upped our subscription.

Iva answered 30/3, 2022 at 12:35 Comment(0)
L
0

I was facing the same issue with my .NET application.

ISSUE: The .NET version that I was using is 4.0 which was creating the whole mess.

REASON: The whole reason behind the issue is that Microsoft has revoked the support for TLS 1.0 and TLS 1.1 for the earlier versions of the .NET framework than 4.6.

FIX: You just need to update the .NET framework version to 4.6 or higher to fix the issue.

Ligniform answered 8/6, 2022 at 14:2 Comment(0)
M
0

Updating the .NET Framework target for the project fixed the issue for me.

Mer answered 26/7, 2022 at 4:40 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Fleawort
This would fix it with higher .NET version, since they default to TLS 1.2 connectionsEsemplastic
H
0

Below is the code that work for me

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

// Create the email object first, then add the properties.
SmtpClient client = new SmtpClient()
{
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    //Set Credentials
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential(_username, _password),
    Host = "smtp.office365.com"
};
client.Send(mail);
Handmaiden answered 14/9, 2022 at 9:37 Comment(0)
D
0
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12

its work for me. Security protocole about framework used

Deannedeans answered 24/1, 2023 at 10:47 Comment(0)
B
0

For those who encounter a similar error, sometimes it is just because when debugging, you exceed the MailKit.Net.Smtp.SmtpClient.Timeout property (which is set to 100000 milliseconds as default value).

Bopp answered 22/3, 2023 at 8:0 Comment(0)
I
0

Lending a line from the PowerShell world, and my script needed the following to be added and work as expected.

HTH!

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13
Indistinguishable answered 15/5, 2023 at 17:44 Comment(0)
S
-1

Prepare: 1. HostA is SMTP virtual server with default port 25 2. HostB is a workstation on which I send mail with SmtpClient and simulate unstable network I use clumsy

Case 1 Given If HostB is 2008R2 When I send email. Then This issue occurs.

Case 2 Given If HostB is 2012 or higher version When I send email. Then The mail was sent out.

Conclusion: This root cause is related with Windows Server 2008R2.

Scurrilous answered 5/12, 2018 at 10:55 Comment(0)
H
-1

I have Found the Ultimate Answer to this. I've been on this error for about a week and found a nuget package that fixed this problem with smtp. You can use MailKit nuget and use it. to learn how to use it, you can just google it's name and you will find a github repository that He explained fully in Readme file.

Herries answered 17/9, 2022 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.