C# yandex mail send error 5.5.4 Error: send AUTH command first

前端 未结 5 883
借酒劲吻你
借酒劲吻你 2021-01-15 06:14

I try to send mail using C# and yandex, but I get an error:

Error 5.5.4 Error: send AUTH command first

Here is my code. I try w

5条回答
  •  情歌与酒
    2021-01-15 06:35

    You must set sc.Credentials = new System.Net.NetworkCredential() after calling sc.UseDefaultCredentials = false;

    UseDefaultCredentials = false will reset Credentials to null

    try to switch lines order to:

    sc.UseDefaultCredentials = false;
    sc.Credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["Email"].ToString(), 
                                                      System.Configuration.ConfigurationManager.AppSettings["Sifre"].ToString());
    

    also valid settings for smtp.yandex.ru:

        smtpUserName=""
        enableSsl="true"
        smtpPassword=""
        smtpAuthentication="Basic"
        smtpServer="smtp.yandex.ru"
        smtpPort="465"
    

提交回复
热议问题