我只是想知道我是否有正确的代码来检查代理是否支持SMTP。我不是垃圾邮件发送者,也不是随意让我感兴趣的东西。我有这个测试:
//host = proxy IP address
public static void can_mail(string host)
{
MailMessage msg = new MailMessage();
msg.Body = "Email is working!";
msg.From = new MailAddress("me@whatever.com");
msg.IsBodyHtml = false;
msg.Subject = "Mail Test";
msg.To.Add(new MailAddress("myemailaddress@myserver.com"));
try
{
SmtpClient client = new SmtpClient();
client.Host = host;
client.Port = 25;
client.EnableSsl = false;
client.Send(msg);
Console.WriteLine("{0} connected, mail probably works?", host);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.Read();
}
我错过了什么吗?