I'm trying to send an email using System.Net.Mail
and am having some issues. It works as intended in the production environment("IIS Express(Google Chrome)" on Visual Studio, apologies if my terminology isn't clear). However, once I publish and create a public domain with (my domain).azurewebsites.net, I get the error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required.
Allow less secure apps is on, and upon the first attempt to sign in I got a "suspicious sign in attempt" on Google which I verified as me. Here is the calling code:
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new NetworkCredential("myemail@gmail.com", "mypassword");
I can't seem to find anything on this, so my problem is either rare and complex or I'm being very silly. I strongly lean towards the latter, but I'd really appreciate any insight.