可能重复:
由于目标机器主动拒绝,无法建立连接?
我在 Asp.net 中发送邮件时遇到严重问题,如果有人知道,请告诉我解决方案。这是我发送邮件的代码
MailMessage mm = new MailMessage();
SmtpClient smtp = new SmtpClient();
mm.From = new MailAddress(txtfrom.Text);
mm.To.Add(new MailAddress(txtto.Text));
mm.Subject = txtsubject.Text;
mm.Body = txtmessage.Text;
mm.IsBodyHtml = true;
smtp.Host = "smtp.gmail.com"; //You can add this in the webconfig
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "mymail@gmail.com";
NetworkCred.Password = "my password";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587; //this is Gmail port for e-mail
smtp.Send(mm);//send an e-mail
问题是当我点击发送按钮时它显示以下错误
“无法建立连接,因为目标机器主动拒绝它 173.194.79.109:587”
请告诉我解决方案..