despite all the topics about this on Stackoverflow. I can't manage to find the solution of this problem:
i have this exception :
SMTP server needs a secure connection or the client is not authentificated. Reply from the server is : 5.5.1 Authentication Required. Learn more at
using this code:
var fromAddress = new MailAddress(user.Email, "From Name");
var toAddress = new MailAddress("myadress@gmail.com", "To Name");
const string fromPassword = "fromPassword";
const string subject = "Subject";
const string body = "Body";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
What am i missing please? thanks for your help