1

I am using .net version 3.5 for sending mails though my web application

I get the following error:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated

What could be causing this?

Curtis Inderwiesche
  • 4,940
  • 19
  • 60
  • 82
kumar
  • 11
  • 1
  • 2

3 Answers3

2

Source from here http://www.systemnetmail.com/faq/4.2.aspx

//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");

//to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential("username", "secret"); 
smtp.Send(mail);

EDIT: This error means what it's written: smtp server needs authentication information (username and password). So, you need set SmtpClient.Credentials.

VikciaR
  • 3,324
  • 20
  • 32
0

Try:

smtpclient.EnableSsl = true;
leppie
  • 115,091
  • 17
  • 196
  • 297
  • iths giving this error now : The remote certificate is invalid according to the validation procedure. – kumar May 20 '11 at 11:10
  • 1
    @kumar check this out [a hack](http://stackoverflow.com/questions/777607/the-remote-certificate-is-invalid-according-to-the-validation-procedure-plea) – V4Vendetta May 20 '11 at 11:36
0

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated

so you need to authenticate by adding credentials

smtpClient.Credentials = new NetworkCredential("username", "password"); 
Yaur
  • 7,333
  • 1
  • 25
  • 36