我使用SmtpClient和MailMessage发送邮件,但邮件是垃圾邮件而不是收件箱 [英] i am sending mail using SmtpClient and MailMessage , but the mail is going to spam and not in inbox

查看:150
本文介绍了我使用SmtpClient和MailMessage发送邮件,但邮件是垃圾邮件而不是收件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用SmtpClient和MailMessage对象发送邮件。邮件正在成功设置,但转到垃圾邮件而不是收件箱。请在我的代码中建议我添加更多内容。



这里是我的代码..

i am trying to send mail using SmtpClient and MailMessage object. Mail is being set succesfully but going to SPAM and not in inbox. Please suggest me what to add more here in my code.

here is my code..

public void SendMail(string from, string pwd ,string to)
   {
       try
       {
           SmtpClient smtp = new SmtpClient();
           smtp.Host = "smtp.gmail.com";
           smtp.Port = 587;
           smtp.EnableSsl = true;
           smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
           smtp.Credentials = new System.Net.NetworkCredential(from, pwd);

           MailMessage Msg = new MailMessage(from, to, "Demo Mail", txtStfComments.Text);
           Msg.IsBodyHtml = false;
           smtp.Send(Msg);
       }
       catch (Exception ex)
       {
           throw ex;
       }
   }





i我在点击按钮事件时调用此功能。



编辑:删除敏感信息。



i am calling this function on click event of a button.

removed sensitive information.

推荐答案

这不是导致此问题的代码:它是内容,或者地址来自。



它可能是主题,电子邮件中的消息或链接 - 任何东西都可以触发垃圾邮件过滤器。



更改消息,看看是否有帮助。
It's not the code that causes this: it's the content, or address it comes from.

It could be the subject, the message in your email, or links - anything can trigger a spam filter.

Change the message and see if that helps.


这篇关于我使用SmtpClient和MailMessage发送邮件,但邮件是垃圾邮件而不是收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆