使用ASP.NET Web应用程序错误发送电子邮件 [英] error sending email using ASP.NET web app

查看:183
本文介绍了使用ASP.NET Web应用程序错误发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送电子邮件到我的网站的用户(ASP.NET,VS2010),我目前使用我的Gmail帐户发送电子邮件,但我得到了以下错误:

I'm trying to send email to my site users (ASP.NET, VS2010), currently I'm using my gmail account for sending email, but I'm getting the following error:

ex = {"Failure sending mail."}
InnerException = {"The remote name could not be resolved: 'smtp@gmail.com'"}

这是我的code:

it is my code:

MailMessage mailObj = new MailMessage("mygmailaccount@gmail.com", "myyahooaccount@yahoo.com", "test", "test2");
            SmtpClient SMTPServer = new SmtpClient("smtp@gmail.com");
            SMTPServer.Credentials = new System.Net.NetworkCredential("mygmailaccount", mygmailpassword);
            try
            {
                SMTPServer.Send(mailObj);
            }
            catch (Exception ex)
            {
                string a = ex.Message;
            }

这是怎么回事错在这里?我应该做我的web.config的东西吗?我怎么能找到我自己的主机的SMTP服务器?

what is going wrong here? should I do something in my web.config? how can I find smtp server of my own host?

推荐答案

smtp@gmail.com 不正确。你可能意味着 smtp.gmail.com 。请参见下面的问题一个完整的例子。

smtp@gmail.com is incorrect. You probably meant smtp.gmail.com. See the following question for a complete example.

通过Gmail发送 .NET中的电子邮件

Sending email in .NET through Gmail

这篇关于使用ASP.NET Web应用程序错误发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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