Click here to Skip to main content
13,048,584 members (92,200 online)
Rate this:
Please Sign up or sign in to vote.
See more:
here is my code:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.Subject = "Nici un Clinet valabil pentru reparare";
                    message.From = new System.Net.Mail.MailAddress("");
                    message.Body = "Nu mai sunt clienti la care mecanicii sa lucreze";
                    string sendEmailsFrom = "";
                    string sendEmailsFromPassword = "my_invisible_password";
                    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("", 587);
                    smtp.EnableSsl = true;
                    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtp.Credentials = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword);
                    smtp.Timeout = 20000;

And my error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

What is the problem? i can't see it and can't find a solution on google.

Sas Gabriel

What I have tried:

Posted 12-Nov-12 10:48am
Updated 2-Mar-17 19:56pm
Richard Deeming 19-Dec-16 12:50pm
I see you've edited your question to remove your email address. However, it's still visible in the revision history. You'll need to contact the site administrators to get that removed.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to set
UseDefaultCredentials = false;
first and after that set the credentials you want to use

Credentials = new NetworkCredential("", "my_invisible_password");

Also make sure you can login from with your username and password from the page.

Good luck,
Gabriel Sas 12-Nov-12 17:04pm
also the password wasn't the good one, thanks
veera kishore 3-Oct-16 8:17am
pls tell me i don't know how to add this credential

this is my code pls make sure tell me the solution.

if (ds.Tables[0].Rows.Count > 0)
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(txtEmail.Text);
// Recipient e-mail address.
Msg.Subject = "Your Password Details";
Msg.Body = "Hi, Please check your Login DetailssYour uname: " + ds.Tables[0].Rows[0]["uname"] + "Your pass: " + ds.Tables[0].Rows[0]["pass"] + "";
Msg.IsBodyHtml = true;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "";
smtp.Port = 587;
UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("", "yourpassword");
Credentials = new NetworkCredential("", "yourpassword");
smtp.EnableSsl = true;
//Msg = null;
lbltxt.Text = "Your Password Details Sent to your mail";
veera kishore 3-Oct-16 8:18am
i used this usedefaultcredential= false as you said..but i had error here.pls find solution
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Also please be aware that google will block you from logging in when you do to much connection attempts.

I always use a local email server for development:[^]
It's free. You can simply configure it and run it on your computer, connecting to localhost:2525.
Please be sure to also turn down the ban-option ("auto-ban") of this one.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Goto Account of Gmail , then select Connected apps & sites Allow less secure apps: ON(if this is off you cannot send mails through apps,or your websites )
Graeme_Grant 3-Mar-17 2:05am
Again, any reason why you are replying to a 5-year-old question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 3 Mar 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100