我正在尝试使用 Kinghost SMTP 发送电子邮件,但出现以下错误:
system.net.mail.smtpException : failure sending mail
任何想法为什么?
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;
}