Asp.net Core中的MailKit身份验证失败

时间:2020-05-02 06:10:06

标签: asp.net-web-api asp.net-core-3.0 asp.net-core-3.1 mailkit mime-message

我正在使用MailKit发送电子邮件和使用office365。这是我尝试发送电子邮件的代码

using (var emailClient = new SmtpClient())
        {
            //// The last parameter here is to use SSL (Which you should!)
            emailClient.Connect(this.emailSetting.SmtpServer, this.emailSetting.SmtpPort, false);
            //// Remove any OAuth functionality as we won't be using it. 
            emailClient.AuthenticationMechanisms.Remove("XOAUTH2");                
            emailClient.Authenticate(this.emailSetting.SmtpUsername, this.emailSetting.SmtpPassword);
            await emailClient.SendAsync(message);
            emailClient.Disconnect(true);
        }

当此行执行emailClient.Authenticate(this.emailSetting.SmtpUsername,this.emailSetting.SmtpPassword)时;它的回报** 5.7.3身份验证失败[DXXP273CA0024.AREP273.PROD.OUTLOOK.COM] **错误

0 个答案:

没有答案