查询表单错误 - SMTP服务器需要安全连接 [英] Enquire form Error - The SMTP server requires a secure connection
本文介绍了查询表单错误 - SMTP服务器需要安全连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要你的帮助。
你能告诉我哪些代码错了。
什么时候我在联系表单上提交了一些详细信息然后我收到了一个错误MSG -
SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应是: 5.5.1需要验证。了解更多信息
你可以帮我......紧急基本..
下面提到的代码 -
I need your help.
Can you suggest me which code is wrong.
When i submit some details on contact form then i received a error MSG -
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"
can you help me... urgent basic ..
below mentioned code -
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (Validation())
{
try
{
SqlCommand cmd = new SqlCommand("Insert into Enquiry values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + DropDownList1 .SelectedValue + "','" + TextBox5.Text + "','"+TextBox6.Text +"','"+TxtDegree .Text +"')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential("xyz@gmail.com",
"*******");
client.UseDefaultCredentials = false;
client.Credentials = credentials;
MailMessage msg = new MailMessage();
msg.From = new MailAddress("xyz@gmail.com");
msg.To.Add(new MailAddress("xyz@gmail.com"));
msg.Subject = "Enquiry";
msg.IsBodyHtml = true;
msg.Body = string.Format("<html><head></head><body>ENQUIRY<BR><hr><br> Name : "+TextBox1 .Text +"<br> Email : "+TextBox2 .Text +"<br> Phone : "+TextBox3 .Text +"<br>Course : "+DropDownList1 .SelectedValue+"<br> Degree :"+TxtDegree .Text +"<br> Message : "+TextBox5 .Text +"</body>");
//msg.Body = string.Format("<html><head></head><body>"+TextBox1 .Text +"</body></html>");
//try
//{
client.Send(msg);
//lblMsg.Text = "Your message has been successfully sent.";
//}
//catch (Exception ex)
//{
//// lblMsg.ForeColor = Color.Red;
//lblMsg.Text = "Error occured while sending your message." +
//ex.Message;
//}
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox6.Text = "";
DropDownList1.SelectedValue = "0";
TextBox5.Text = "";
TxtDegree.Text = "";
Label1.Text = "Enquiry submitted!";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
}
protected bool Validation()
{
if (TextBox1.Text.Trim() == "")
{
Label1.Text = "Enter name!";
TextBox1.Focus();
return false;
}
if (TextBox2.Text.Trim() == "")
{
Label1.Text = "Enter email id!";
TextBox2.Focus();
return false;
}
if (TextBox3.Text.Trim() == "")
{
Label1.Text = "Enter phone no!";
TextBox3.Focus();
return false;
}
//if (TextBox4.Text.Trim() == "")
//{
// Label1.Text = "Enter course!";
// TextBox4.Focus();
// return false;
//}
if (TextBox5.Text.Trim() == "")
{
Label1.Text = "Enter message!";
TextBox5.Focus();
return false;
}
return true;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session.Abandon();
Response.Redirect("Default.aspx");
}
}
推荐答案
Hello Priyanka,
造成这种情况的原因很多,您的代码无法识别问题
您可以快速参考这些来尝试解决问题>
http://stackoverflow.com / questions / 32260 / sending-email-in-net-through-gmail [ ^ ]
http://stackoverflow.com/questions/18503333/the-smtp-server-requires-a-安全连接或客户端未经过身份验证 [ ^ ]
所有最佳:)
Hello Priyanka,
There are many causes for this to occur,with your code iam unable to identify the issue
You can refer these quickly to try and solve yourself
http://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail[^]
http://stackoverflow.com/questions/18503333/the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated[^]
All the Best:)
>
您好,
发生此问题的原因可能是密码不足。
参考链接:5.5.1 smtp.gmail.com所需的身份验证
还要检查:这个
谢谢
Hello ,
This problem occurs may be for weak password .
Refer link : 5.5.1 Authentication Required with smtp.gmail.com
also check : This
thanks
问题是小密码。你必须使用强PAssword。
the problem is small password.You have to use a Strong PAssword.
这篇关于查询表单错误 - SMTP服务器需要安全连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文