我正在为服务器开发一个应用程序,它必须偶尔发送邮件以通知用户。
MailMessage mm = new MailMessage();
mm.To.Add("me@domain.net");
mm.From = new MailAddress("you@domain.net");
mm.Subject = "J/K";
mm.Priority = MailPriority.Normal;
mm.IsBodyHtml = false;
mm.Body = "Greetings and salutations";
SmtpClient client = new SmtpClient("host.address.lcl");
client.Send(mm);
如果我将应用程序放在实际的服务器上,它可以正常工作,但在我的工作站上,取决于我访问代码的方式,它要么静默失败,要么抛出异常。无论哪种情况,都会生成 McLogEvent:
Blocked by port blocking rule (Anti-virus Standard Protection:Prevent
mass mailing worms from sending mail).
...例外说:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException:
Unable to connect to the remote server ---> System.Net.Sockets.SocketException:
No connection could be made because the target machine actively refused it [IP & Port Numbers]
看起来我的工作站上的一条规则正在直接或间接地阻止生成邮件,但我不确定如何处理“主动拒绝它”部分,因为如果 McLogEvent 文本似乎暗示它不会走那么远。
我应该指出,如果我使用 System.Web.Mail 效果很好。缺点当然是有关此命名空间的编译器消息已被弃用,取而代之的是 System.Net.Mail。
任何人都知道如何通过从我的工作站发送邮件来让 McAfee 变得更酷?