I have a form that sends me a email to my gmail for work email address. The email address works, just not from my website app. (Using asp mvc)
I tested this code to work on godaddy with their email and with my personal gmail and it works, but not with google business, I get a syntax error. I believe its set up correctly base off google settings https://support.google.com/a/answer/176600?hl=en
This is what I got set up
using (var smtp = new SmtpClient())
{
var credential = new NetworkCredential
{
UserName = "mysite@example.com",
Password = "password"
};
smtp.Credentials = credential;
smtp.Host = "smtp.gmail.com";
smtp.Port = 465;
smtp.EnableSsl = true;
await smtp.SendMailAsync(message);
await smtp.SendMailAsync(CustomerMsg);
return RedirectToAction("Sent");
}
}
return View(model);
the error I'm getting is
System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was:
the error is at this line
Line 79:await smtp.SendMailAsync(message);