• Register
0 votes
94 views

Problem :

I am using a SmtpClient library to send the emails using a below code :

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

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

I have also confirmed that the firewalls are not the issue. A port opens just fine between a client and a server. I am not sure at all what else could throw above error.

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have faced the same problem and was able to solve my problem by changing Smtp Client to the Mailkit. A System.Net.Mail Smtp Client is now not at all recommended to use by the Microsoft because of the security issues and so you should instead be using the MailKit. Using the Mailkit gave me a clearer error messages that I could understand finding a root cause of my problem and it was license issue. You can also get Mailkit by downloading it as the Nuget Package.

Please read documentation about the Smtp Client for more information on following link: https://docs.microsoft.com/es-es/dotnet/api/system.net.mail.smtpclient?redirectedfrom=MSDN&view=netframework-4.7.2

9 7 4
38,600 points

Related questions

0 votes
1 answer 17 views
0 votes
1 answer 4 views
4 views
Problem: HI there I have an issue that i am unable to read data from the transport connection
asked Mar 18 waseem memon 2.4k points
0 votes
1 answer 10 views
10 views
Problem: Gmail Error:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
asked Mar 20 ummesalma 22.8k points
0 votes
1 answer 290 views
290 views
Problem : I want to send mails using my web application. But my below code is showing me the below error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send ... false; mysmtp.Timeout = 600000; } // Passing values to smtp object mysmtp.Send(myfromAddress, mytoAddress, mysubject, mybody); } } }
asked Dec 9, 2019 alecxe 7.5k points
1 vote
1 answer 8 views
8 views
Problem: How to solve this problem? The client and server don't support a common ssl protocol version or cipher suite.
asked Mar 29 PkGuy 13.1k points
0 votes
1 answer 2 views
2 views
Problem: The server response was 5.5.1 authentication required. help me to clear this issue.
asked Mar 21 charles mathews 5.5k points
0 votes
0 answers 2 views
2 views
Problem: I am geeting this message from my server. Secure connection failed the connection to the server was reset while the page was loading.
asked Mar 26 PkGuy 13.1k points
0 votes
1 answer 1 view
1 view
Problem: Please help me fix this dilemma “The smtp server requires a secure connection or the client was not authenticated 5.5.1”?
asked Mar 29 tuhin1 47.2k points
0 votes
1 answer 9 views
9 views
Problem: Please help me … how can I solve this that client was not authenticated to send anonymous mail during mail from?
asked Mar 18 Ifra 24.4k points
0 votes
1 answer 271 views
271 views
Problem : I want to tell you that I have researched a lot for this issue but without a solution. I have created the loop that will go throw my listBox1 and that contains the links, each time creating the http GET request in order to access my full source ... it's the problem with my certificate as otherwise I would still get the error when I removed my loop. Any suggestions are highly appreciated.
asked Jan 10, 2020 alecxe 7.5k points