我的邮件系统在本地计算机上运行良好,但在网络上却报错 [英] My mail System Running Fine on Local Machine But gives error on Net
本文介绍了我的邮件系统在本地计算机上运行良好,但在网络上却报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有C#的.Net3.5,
这是我的代码
I am using .Net3.5 with C#,
This is my code
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string mailto = "xxxxxxx@gmail.com";
MailMessage messagemail = new MailMessage();
MailMessage mymessage = new MailMessage();
mymessage.From = new MailAddress("yyyyyy@gmail.com");
mymessage.To.Add(mailto);
mymessage.IsBodyHtml = true;
mymessage.Subject = "Queries";
mymessage.Body = "Name:" + TxtName.Text + "\nEmail Id:" + TxtEmailId.Text + "\nAddress:" + TxtAdress.Text + "\nMobile No.:" + TxtMobile.Text + "\nQueries/Feedback:" + TxtQueries.Text + "";
SmtpClient sc = new SmtpClient();
System.Net.NetworkCredential mycred = new System.Net.NetworkCredential("yyyyyy@gmail.com", "********");
sc.Host = "Smtp.gmail.com";
sc.Port = 587;
sc.EnableSsl = true;
sc.UseDefaultCredentials = false;
sc.ServicePoint.MaxIdleTime = 1;
sc.Credentials = mycred;
sc.Send(mymessage);
mymessage.Dispose();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "aa", "javascript:alert('Thanks For Contacting Us. We Will Get Back To You Soon')", true);
TxtName.Text = "";
TxtAdress.Text = "";
TxtEmailId.Text = "";
TxtMobile.Text = "";
TxtQueries.Text = "";
}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "aa", "javascript:alert('"+ ex.Message +"')", true);
}
}
它在本地计算机上运行良好,但是当我上传网页时,出现以下错误
"SMTP服务器需要安全连接,或者客户端未通过身份验证.服务器响应为:5.5.1需要身份验证."
虽然我用过
sc.EnableSsl = true;
请帮助
谢谢
法伊兹
[edit]已添加代码块-OriginalGriff [/edit]
Its running Fine on local machine, but when I upload my web page it gives the following error
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
Although i used
sc.EnableSsl = true;
Please Help
Thanks
Faiz
[edit]Code block added - OriginalGriff[/edit]
推荐答案
在web.config中添加以下内容.希望它能起作用.
Add this following in your web.config. Hope it works.
<trust level="Full" originUrl="www.gmail.com" />
这篇关于我的邮件系统在本地计算机上运行良好,但在网络上却报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文