The SMTP server requires a secure connection or the client was not authenticated. if uploading on godaddy

StackOverflow https://stackoverflow.com/questions/19111325

  •  29-06-2022
  •  | 
  •  

Pergunta

below code is working fine in local, but if upload upload it on godaddy it is not working.

Error: showing

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Line 53:        
Line 54:         smtp.EnableSsl = true;
Line 55:         smtp.Send(message);
Line 56: 
Line 57: 

plz check below code

    MailMessage message = new MailMessage();
    message.From = new MailAddress(emailid.Text);

    message.To.Add(new MailAddress("receiver@gmail.com"));

    message.Subject = "NaatKhawan's Feedback";

    message.Body = "Selected: " + DropDownList1.Text.ToString() + "<br/><br/>Name: " + name.Text.ToString() + " <br/><br/>Email: " + emailid.Text.ToString() + " <br/><br/>Contact Number: " + phone.Text.ToString() + " <br/><br/>Message:<br/> " + remabox.Text.ToString();

    message.IsBodyHtml = true;

    // finaly send the email:
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";

    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("123@gmail.com", "123");

    smtp.EnableSsl = true;
    smtp.Send(message);
    lbltxt.Visible = true;
    name.Text = "";
    emailid.Text = "";
    phone.Text = "";
    remabox.Text = "";

    lbltxt.Text = "Thank you for supporting NaatKhawan";
Foi útil?

Solução

you should enable application to access gmail account. This link will help you

Outras dicas

I have the same problem.

I have found this solution:

Google may block sign in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.

Some examples of apps that do not support the latest security standards include:

The Mail app on your iPhone or iPad with iOS 6 or below The Mail app on your Windows phone preceding the 8.1 release Some Desktop mail clients like Microsoft Outlook and Mozilla Thunderbird Therefore, you have to enable Less Secure Sign-In in your google account.

After sign into google account, go to:

https://www.google.com/settings/security/lesssecureapps

I just encountered the same problem.

Tried Aidin Eslami's answer and it only did part job:

After enabling less secure apps access in here: https://www.google.com/settings/security/lesssecureapps I managed to send emails from my local machine but not from my web host.

And then I found this google support page: https://support.google.com/accounts/answer/6009563

Still having trouble signing in?

If you’ve tried all the options above but are still unable to sign in to your account on the app, try the following:

Go to https://accounts.google.com/DisplayUnlockCaptcha on your device's browser. Enter your username and password, then type the letters on the screen. Go back to the app and try signing in again.

After pressing the button in the DisplayUnlockCaptcha everything works!

Hopes this helps others too. Good luck.

I also had this issue with sending email from my local application and tried many different suggestions.

After few hours of battling with this it turned out that the issue was related to the fact that I had 2 google accounts and I was using my second account and all setting were correct I even enabled lesssecureapps on this account but it still didn't work. Last thing I tried was to change the SmtpClient setup to use my other Gmail account and it all magically worked.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top