Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir why this problem occures.
****************
MailMessage mailMsg = new MailMessage();

mailMsg.From = new MailAddress(txtemail.Text);

mailMsg.To.Add("xxxxxxxxxxxxxx@gmail.com");

mailMsg.IsBodyHtml = true;

mailMsg.Subject = "Enquery Details";

mailMsg.Body = "Enquery Details" + "Name:" + txtname.Text + "
Email - address :" + txtemail.Text + "
Place :" + txtplace.Text + "
Mobile:" + txtmobile.Text + "
Check In:" + txtdatecheckin.Text + "
Check Out:" + txtcheckout.Text + "
Message:" + TextBox2.Text;

SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

mailMsg.Priority = MailPriority.Normal;

smtp.Credentials = new System.Net.NetworkCredential("xxxxxx@gmail.com", "xxxxxxxxxxxxxxxxxxxxxx");

smtp.Timeout = 25000;

smtp.EnableSsl = true;

smtp.Send(mailMsg);
**************************
this code is working fine in local host but upload to server get error:-
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
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: 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

Source Error:


Line 40: smtp.EnableSsl = true;
Line 41:
Line 42: smtp.Send(mailMsg);
Line 43: }
Line 44: }
sir plz help me thans.
Posted
Comments
F-ES Sitecore 25-Aug-15 5:28am    
Don't send email through gmail's server. If you must then google this error message, this is the most frequently asked question and there are hundreds of similar threads.

1 solution

So look at the message: it couldn't be any clearer if it tried:
The SMTP server requires a secure connection or the client was not authenticated.
So check your user ID, check your password.

It's rejecting your request because it doesn't like one of them...
 
Share this answer
 
Comments
Member 10506503 25-Aug-15 6:06am    
this code is working fine in local host
but upload server than error occure sir plz help me sir

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900