无法建立连接,因为目标机器主动拒绝72.14.213.109:587
//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("[email protected]", "[email protected]",
"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("[email protected]", "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
代码参考:这里
请告诉我如何找到它?
//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("[email protected]", "[email protected]",
"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("[email protected]", "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);
Thats my code & it throws error :
No connection could be made because the target machine actively refused it 72.14.213.109:587
Code Reference : here
Please tell me how can i sought it out ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
检查以下两点
1- 检查您的计算机上的端口 587 是否已打开
2- 检查您的防病毒软件是否阻止了与您的端口的连接
此致。
Check both of the following points
1- Check that this port 587 is open on your machine
2- Check if your antivirus is blocking the connection to your port
Regards.
如果您正在运行任何防病毒软件,请检查访问保护,取消阻止“防止群发邮件蠕虫发送邮件”
If your have any antivirus software running, check the access protection, unblock "prevent mass mailing worms from send mail"
您实际上更改了用户名和密码吗?
Did you actually change the username and password?