I am trying to send email in c# using gmail smtp server but it giving me an error `Failure sending mail``.
Everything is fine username and password. What wrong with this code that can cause this error?
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "mypassword"),
EnableSsl = true
};
client.Send("[email protected]", "[email protected]", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();
I think this will more helpfull to you https://support.google.com/a/answer/176600?hl=en