我正在尝试向我的网站用户发送电子邮件(ASP.NET,VS2010),目前我正在使用我的Gmail帐户发送电子邮件,但是我收到以下错误:
ex = {"Failure sending mail."}
InnerException = {"The remote name could not be resolved: 'smtp@gmail.com'"}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
这里出了什么问题?我应该在web.config中做些什么吗?我怎样才能找到自己主机的smtp服务器?
| 归档时间: |
|
| 查看次数: |
4094 次 |
| 最近记录: |