I am making an SMTP mail application with C # .Net. It works fine for Gmail settings, but I have to work with it to connect to VSNL. I get an exception: "Mail sending failure"
My settings seem perfect. What is the problem? Why am I getting an exception?
MailMessage mailMsg = new MailMessage(); MailAddress mailAddress = new MailAddress(" mail@vsnl.net "); mailMsg.To.Add(textboxsecondry.Text); mailMsg.From = mailAddress; // Subject and Body mailMsg.Subject = "Testing mail.."; mailMsg.Body = "connection testing.."; SmtpClient smtpClient = new SmtpClient("smtp.vsnl.net", 25); var credentials = new System.Net.NetworkCredential(" mail@vsnl.net ", "password"); smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = credentials; smtpClient.Send(mailMsg);
I get an exception after ...
System.IO.IOException: Unable to read data from transport connection: net_io_connection closed.
in System.Net.Mail.SmtpReplyReaderFactory.ProcessRead (byte buffer [], Int32 offset, Int32 read, logical readLine)
in System.Net.Mail.SmtpReplyReaderFactory.ReadLines (smtpReplyReader caller, Boolean oneLine)
in System.Net.Mail.SmtpReplyReaderFactory.ReadLine (call SmtpReplyReader)
on System.Net.Mail.SmtpConnection.GetConnection (host String, port Int32) in System.Net.Mail.SmtpTransport.GetConnection (host String, port Int32)
in System.Net.Mail.SmtpClient.GetConnection ()
in System.Net.Mail.SmtpClient.Send (MailMessage message)
source share