请在此确定错误 [英] Please identify error in this

查看:43
本文介绍了请在此确定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此代码发送邮件时,我收到如下错误:

 SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为: 5  5  1 需要验证  





使用System.Net.Mail;
使用System.Text;

public partial class _Default:System.Web.UI.Page
{
/ * Mail将发送的用户信用* /
private const String FROM =
我的电子邮件 ;
private const String userName = FROM;
private const String PassWord =
密码 8 chars ;
private String MailTitle =
;
private String MailBody =
;
protected void Page_Load(object sender,EventArgs e)
{

}
protected void Button1_Click(object sender,EventArgs e)
{
尝试{
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host =
smtp.gmail.com ;
client.EnableSsl = true;
client.Timeout = 1000000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential(userName,PassWord);

MailTitle =
测试邮件通知! ;
MailBody =
简单邮件测试程序! ;
MailMessage mm = new MailMessage(FROM,TextBox3.Text,MailTitle,
< h1>< u> + MailBody + < / u > < / h1 > );
mm.IsBodyHtml = true; / * TO sebd HTML格式化数据!* /
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

client.Send(mm);
Response.Write(
邮件已成功发送 );
}
catch(Exception ex){
Response.Write(ex.Message);


}





我的尝试:



我试过上面的代码,但我说

 SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应是: 5  5  1 需要验证



解决方案

请参考 c# - 如何根据新的安全策略在.Net中发送电子邮件? [ ^ ]

When I run this code to send Mail, I am getting error like this:
"

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required"





using System.Net.Mail;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    /*User Crediatials by which Mail would sent */
    private const String FROM = "my email";
    private const String userName = FROM;
    private const String PassWord = "password of 8 chars";
    private String MailTitle = "";
    private String MailBody = "";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try {
            SmtpClient client = new SmtpClient();
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl= true;
            client.Timeout = 1000000;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = true;
            client.Credentials = new System.Net.NetworkCredential(userName,PassWord);
           
            MailTitle = "Test Mail Notification !";
            MailBody = "This is a Simple Mail Tester !";
            MailMessage mm = new MailMessage(FROM,TextBox3.Text,MailTitle,"<h1><u>"+ MailBody+"</u></h1>");
            mm.IsBodyHtml = true;/*TO sebd HTML Formatted Data !*/
            mm.BodyEncoding = UTF8Encoding.UTF8;
            mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

            client.Send(mm);
            Response.Write("Mail Sent Successfully");
        }
        catch (Exception ex) {
            Response.Write(ex.Message);

        
        }



What I have tried:

I tried above code but i says "

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required


"

解决方案

Please refer c# - How to send an email in .Net according to new security policies?[^]


这篇关于请在此确定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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