Can't auth to Gmail smtp via MailMessage & smtpClient

后端 未结 11 1358
遇见更好的自我
遇见更好的自我 2020-11-30 06:55

I cannot figure out for the life of my why this isn\'t working

SmtpClient smtp = new SmtpClient
{
    Host = \"smtp.gmail.com\",
    Port = 587,
    UseDefau         


        
11条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 07:31

    For me the solution required 2 "steps":

    • set UseDefaultCredentials = false first, then set the credentials I want to use Credentials = new NetworkCredential("myemail@gmail.com", "myGmailPasswordHere"). Setting the credentials first, when I set UseDefaultCredentials = false will make the Credentials property null.
    • Allow less secure apps on my Google profile.

提交回复
热议问题