GMAIL和YahooMail發生5.7.1 Authentication required Error

  • 507
  • 0
  • c#
  • 2018-01-09

今天寫一個寄信小程式通過GMAIL發生5.7.1 Authentication required Error

 

source code

      static void Gmail() {
            MailMessage mail = new MailMessage("寄信人mail", "收信人mail");

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
            smtp.Credentials = new System.Net.NetworkCredential("mail帳號", "mail帳號");
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            //smtp.UseDefaultCredentials = false;
            smtp.Send(mail);
        }

後來找了一下資料

發現Google和Yahoo寄信時要注意兩個地方

1.開啟允許較低權限的應用程式

2.確認設置應用程式密碼並使用創建之密碼登入

Yahoo Mail

https://help.yahoo.com/kb/account/add-two-step-verification-extra-security-sln5013.html?impressions=true

GMAIL

https://support.google.com/accounts/answer/185833?hl=tw


如果本文對您幫助很大,可街口支付斗內鼓勵石頭^^