• Register
0 votes
41 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

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 12 views
0 votes
1 answer 209 views
209 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
0 votes
1 answer 351 views
351 views
Problem : I am trying to create the test app using unity but facing following issue: readpixels was called to read pixels from system frame buffer, while not inside drawing frame.
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 190 views
190 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 alecxe 7.5k points