asp.net代码中发送错误信息 [英] error in asp.net code to send email

查看:54
本文介绍了asp.net代码中发送错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误无法解析远程无法解析远程名称:'smtp.gmail.com'或此发送邮件失败。系统

.i在代理服务器上使用互联网。如何纠正上述错误



hi am getting this error "could not resolve remote "The remote name could not be resolved: 'smtp.gmail.com'" or this one "Failure sending mail.System
".i use internet on proxy sever. how to rectify the said error

      MailMessage msg = new MailMessage();
       msg.From = new MailAddress("demoejk@gmail.com");
       msg.To.Add("demoejk@gmail.com");
       msg.Subject = "Sucessfull Regesiration to F2";
       msg.IsBodyHtml = true;
       msg.Body = "Congrats " + TextBox1.Text + "  u have been sucessfully registred to F2 Keep visiting regularly ";
       SmtpClient client = new SmtpClient("Smtp.gmail.com", 587);
       client.Credentials = new NetworkCredential("demrike", "XXXXXXXX");
       client.EnableSsl = true;
       try
       {
           client.Send(msg);
           Response.Write("mes has been sent");
       }
       catch (Exception er)
       {
           Response.Write(er.Message);
           Response.Write(er.Source.ToString());
>      }

推荐答案

是你能从你的计算机ping smtp.gmail.com吗?
Are you able to ping smtp.gmail.com from your computer?


你的代码没有问题。

因为你使用的是ASP.NET,你能不能尝试在web.config文件中添加以下内容



There is nothing wrong with your code.
Since you are using ASP.NET, can you try adding the following in web.config file

<system.net>
	<defaultproxy>
		<proxy proxyaddress="ip address of proxy server" />
	</defaultproxy>
</system.net>


错误是自描述的,系统无法从您的计算机访问Smtp.gmail.com。

1.检查防火墙设置

2.尝试从你的机器ping smtp.gmail.com

3.打开命令提示符,然后输入nslookup www.gmail.com 。看看你是否得到回复和域名ip

如果没有那么你的域名设置
The error is self descriptive, system unable to access Smtp.gmail.com from your machine.
1. check firewall settings
2. try pinging Smtp.gmail.com from your machine
3. open a command prompt, and type "nslookup www.gmail.com". see if you get response and domain ip
if not then your domain setting


这篇关于asp.net代码中发送错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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