如何通过代理服务器发送邮件在asp.net [英] How to send mail in asp.net through proxy server
本文介绍了如何通过代理服务器发送邮件在asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过asp.net使用下述code发送邮件。 它工作正常,无代理环境。但现在我用代理服务器和使用代理服务器设置工作连接到互联网。 它提供了错误失败发送邮件 请谁能帮助?
MailMessage味精=新MailMessage(xyz@gmail.com,TextBox1.Text);
msg.Subject = TextBox2.Text;
msg.Body = TextBox3.Text;
SmtpClient S =新SmtpClient();
s.Host =smtp.gmail.com;
s.EnableSsl =真;
s.Credentials =新的NetworkCredential(xyz@gmail.com,密码);
s.Send(MSG);
解决方案
添加到您的web.config,并与代理服务器的地址来替换your.proxy.address:
< system.net>
< defaultProxy启用=真正的>
<代理proxyaddress =your.proxy.address/>
< / defaultProxy>
< /system.net>
i am trying to send mail through asp.net using the code mentioned below. it works fine without proxy environment. but now i am working with proxy servers and use proxy settings to connect to internet. it gives error 'Failure Sending Mail' Please anyone help ?
MailMessage msg = new MailMessage("xyz@gmail.com", TextBox1.Text);
msg.Subject = TextBox2.Text;
msg.Body = TextBox3.Text;
SmtpClient s = new SmtpClient();
s.Host = "smtp.gmail.com";
s.EnableSsl = true;
s.Credentials = new NetworkCredential("xyz@gmail.com", "password");
s.Send(msg);
解决方案
Add this to your web.config and replace your.proxy.address with the address of proxy server:
<system.net>
<defaultProxy enabled="true">
<proxy proxyaddress="your.proxy.address"/>
</defaultProxy>
</system.net>
这篇关于如何通过代理服务器发送邮件在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文