2
 //Create Mail Message Object with content that you want to send with mail.
        System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("dotnetguts@gmail.com", "myfriend@yahoo.com",
        "This is the mail subject", "Just wanted to say Hello");

        MyMailMessage.IsBodyHtml = false;

        //Proper Authentication Details need to be passed when sending email from gmail
        System.Net.NetworkCredential mailAuthentication = new
        System.Net.NetworkCredential("dotnetguts@gmail.com", "myPassword");

        //Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
        //For different server like yahoo this details changes and you can
        //get it from respective server.
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

        //Enable SSL
        mailClient.EnableSsl = true;

        mailClient.UseDefaultCredentials = false;

        mailClient.Credentials = mailAuthentication;

        mailClient.Send(MyMailMessage);

那是我的代码,它会抛出错误:无法建立连接,因为目标机器主动拒绝它 72.14.213.109:587

代码参考:这里

请告诉我如何找到它?

4

3 回答 3

3

检查以下两点

1-检查此端口 587 在您的机器上是否打开

2-检查您的防病毒软件是否阻止了与您的端口的连接

问候。

于 2011-01-17T09:22:13.310 回答
1

如果您运行了任何杀毒软件,请检查访问保护,取消阻止“防止群发邮件蠕虫发送邮件”

于 2014-02-27T04:40:16.217 回答
0

你真的改变了用户名和密码吗?

于 2011-01-16T09:03:33.383 回答