I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message
var fromAddres
I have a previously-working code that throws this error now. No issue on password. No need to convert message to base64 either. Turns out, i need to do the following:
Working code
public static void SendEmail(string emailTo, string subject, string body)
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("youremail@gmail.com", "secretpassword"),
EnableSsl = true
};
client.Send("youremail@gmail.com", emailTo, subject, body);
}
Turning off 2-factor authentication
Set "Allow less secure apps" to ON (same page, need to scroll to bottom)