authentication error in sending mail from yahoo in c# windows application

匆匆过客 提交于 2019-12-11 06:12:57

问题


i am trying to send email from my software using the smtp of yahoo but it shows the following error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Authentication required".

I know about the less secure apps setting in google but i don't know about the settings in yahoo. the same code runs fine with the gmail account credentials. here is the code for reference.

string EmailFrom = "test@yahoo.com";
        string EmailTo = "test@gmail.com";
        string PassWord = "test123";
        string EmailHost = "smtp.mail.yahoo.com";
        string status = "";
        string Body = "";

        MailMessage message = new MailMessage();
        SmtpClient smtp = new SmtpClient();

        message.From = new MailAddress(EmailFrom);
        message.To.Add(new MailAddress(EmailTo));
        message.Subject = "Auto Backup at test" ;
        message.Body = "Backup has been taken at test on" + DateTime.Now;
        Body = "Backup has been taken at test on" + DateTime.Now;
        smtp.Port = 587;
        smtp.Host = EmailHost;
        smtp.EnableSsl = true;
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new NetworkCredential(EmailFrom, PassWord);
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        //ServiceLogLibrary.WriteErrorlog("Step:5");
        //Library.WriteErrorlog("Before sending mail");
        smtp.Send(message);

回答1:


You need to go to

  1. Go to your "Account security" settings.
  2. Select Allow apps that use less secure sign in.
  3. To deny or turn off app access, deselect the undesired app.

Source:Temporarily allow or deny access to apps using older security sign in



来源:https://stackoverflow.com/questions/40583661/authentication-error-in-sending-mail-from-yahoo-in-c-sharp-windows-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!