Smtp authentification required [duplicate]

You need to tell the SMTP client that you will not be using your windows credentials to access the SMTP, so add

smtpClient.UseDefaultCredentials = false;

above this line of code

smtpClient.Credentials = new NetworkCredential("[email protected]", "password");

Also, gmail doesn’t allow impersonation, so

mailMessage.From = new MailAddress("[email protected]");

will have no effect – the emails will still appear to be sent from the email account you are accessing.

Also, make sure that the setting “allow less-secure applications” is set on your gmail account, and that 2-factor authentication is not enabled.

Browse More Popular Posts

Leave a Comment