我從我的ASP.net Web應用程序發送電子郵件。C#.Net消息將發送到垃圾郵件文件夾
郵件成功發送失敗,但大多數都是垃圾郵件文件夾。
請幫我過來垃圾郵件過濾器。
我發送郵件代碼
public void SendMail(string FromAddress, string ToAddress, string Subject, string BodyText)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(FromAddress,"My Name");
mailMsg.To.Add(new MailAddress(ToAddress));
mailMsg.Subject = Subject;
mailMsg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
(System.Text.RegularExpressions.Regex.Replace(BodyText, @"<(.|\n)*?>", string.Empty), null, "text/plain");
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, "text/html");
mailMsg.AlternateViews.Add(plainView);
mailMsg.AlternateViews.Add(htmlView);
// Smtp configuration
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.mysite.com";
smtp.Credentials = new System.Net.NetworkCredential(FromAddress, "password");
smtp.EnableSsl = false;
try
{
smtp.Send(mailMsg);
}
catch (Exception ex)
{
throw ex;
}
}
我懷疑這與.NET或C#有什麼關係。這些消息的內容是什麼? –
同意:這與內容有關。當我查看代碼時,內容似乎爲空... – Jan
您是否查看了垃圾郵件文件夾中郵件的標題?可能會添加分類標題,解釋爲什麼它被標記爲垃圾郵件。您是否從具有有效的現有電子郵件域的電子郵件地址發送郵件? –