Here is my code.
var smtp = new SmtpClient("smtp.gmail.com", 587)
{
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("sender@gmail.com","123")
};
try
{
smtp.Send("sender@gmail.com", "receiver@gmail.com", "test", "testbody");
}
catch (SmtpException e)
{
ltrInfo.Text=e.Message;
}
When I debug the code, I get the error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required" Please can you tell me what's the wrong with the code above?