如何为Asp.Net授权Google Stmpt ..当我使用时出现以下错误 [英] How To Authorize The Google Stmpt For Asp.Net.. Got Following Error When I Use

查看:39
本文介绍了如何为Asp.Net授权Google Stmpt ..当我使用时出现以下错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using (MailMessage mm = new MailMessage("m@gmail.com", txtEmail.Text))
    {
        mm.Subject = "Account Activation";
        string body = "Hello " + txtUsername.Text.Trim() + ",";
        body += "<br /><br />Please click the following link to activate your account";
        body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("CS.aspx", "CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";
        body += "<br /><br />Thanks";
        mm.Body = body;
        mm.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.EnableSsl = true;
        NetworkCredential NetworkCred = new NetworkCredential("m.@gmail.com", "pssword");
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.Send(mm);
    }
}
i got this error"" An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

推荐答案

我认为您需要在FROM中使用您的gmail帐户和这些凭据地址。

否则谷歌会将此视为安全问题。
I think you need to use your gmail account with those credentials in "FROM" address.
Otherwise google will treat this as security issue.


这篇关于如何为Asp.Net授权Google Stmpt ..当我使用时出现以下错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆