C# system.net.mail.smtpException:无法连接到远程服务器?
我正在尝试使用Kinghost SMTP发送电子邮件,但出现以下错误:C# system.net.mail.smtpException:无法连接到远程服务器?,c#,windows-7,C#,Windows 7,我正在尝试使用Kinghost SMTP发送电子邮件,但出现以下错误: system.net.mail.smtpException:发送邮件失败 你知道为什么吗 private bool SendEmail( string sendto, string sendfrom, string subject, string body ) { bool status = false; try {
system.net.mail.smtpException:发送邮件失败
你知道为什么吗
private bool SendEmail( string sendto, string sendfrom, string subject, string body )
{
bool status = false;
try
{
msg.To.Clear();
clint.Host = "smtp.kinghost.net";
clint.Port = 25;
clint.UseDefaultCredentials = false;
clint.Credentials = smtpCrede;
clint.EnableSsl = true;
MailAddress to = new MailAddress(sendto);
MailAddress from = new MailAddress(sendfrom);
msg.Subject = subject;
msg.Body = body;
msg.From = from;
msg.To.Add(to);
clint.Send(msg);
status = true;
}
catch ( Exception ex )
{
MessageBox.Show(ex.ToString());
}
return status;
}
您的ISP可能正在阻止端口25上的出站连接
尝试端口587。我在防火墙中添加了端口25。若我使用587,那个么例外是事务脆弱器。你们的ISP可能正在阻止端口25,不管你们的防火墙如何(询问他们)。联系您的主机并询问他们接受哪些端口。