我想配置使用C#的邮件。
这里是我的代码,我得到上述错误
。请帮我解决这个问题。
public bool Send()
{
string user = ConfigurationManager.AppSettings["email_username"].ToString();
string password = ConfigurationManager.AppSettings["email_password"].ToString();
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential(user, password);
SmtpServer.Port = 25;
SmtpServer.Host = "smtp.rediffmail.com";
SmtpServer.EnableSsl = true;
MailMessage mail = new MailMessage();
try
{
mail.From = new MailAddress(user, "SUBJECT", System.Text.Encoding.UTF8);
mail.To.Add(new MailAddress(to));
mail.Subject = subject;
mail.Body = message;
mail.IsBodyHtml = true;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(frm);
SmtpServer.Send(mail);
}
catch (Exception err)
{
return false;
}
return true;
}
预先感谢| biswarup88:爱德华・卢