通过c#发送电子邮件会发送垃圾邮件

时间:2015-09-03 22:00:16

标签: c# sendmail

我使用该方法发送电子邮件:

    public void Enviar(MailAddress from, MailPriority prioridade)
    {
        SmtpClient client = new SmtpClient(new PartnerDB().ParServidorSMTP);
        MailMessage mail = new MailMessage();
        mail.From = from;
        mail.Subject = this.Assunto;
        mail.Priority = prioridade;
        mail.IsBodyHtml = true;
        mail.Body = this.Conteudo;

        foreach (var email in this.Para) mail.To.Add(new MailAddress(email));
        foreach (var email in this.Copia) mail.CC.Add(new MailAddress(email));
        foreach (var email in this.CopiaOculta) mail.Bcc.Add(new MailAddress(email));
        foreach (var anexo in this.CaminhoAnexos) mail.Attachments.Add(new Attachment(anexo));
        foreach (var anexo in this.StreamAnexos) mail.Attachments.Add(new Attachment(anexo.StreamBytes, anexo.MimeType));

        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            Log.Instancia.LogError(new SiteSession().User.Login, "SendMail.Enviar", ex, this.Assunto);
        }

        mail.Dispose();
    }

调用方法更改电子邮件地址,并将其转换为垃圾邮件,其他不是,如下面的示例:

            {
                string corpo = "Testing email via C#";
                var mail = new SendMail("eduardo.chafick@hotmail.com", "subject testing via c# eduardo", corpo);
                mail.Enviar(new MailAddress("xxxxx@xxxxxxxx.com"), MailPriority.High);
            }

            {
                string corpo = "Testing email via C#";
                var mail = new SendMail("eduardo.chafick@hotmail.com", "subject testing via c# leanndro", corpo);
                mail.Enviar(new MailAddress("yyyyyyy@yyyyyyyyy.com"), MailPriority.High);
            }

当我使用MailAddress(from)作为' eduardo.chafick@hotmail.com'电子邮件发送到垃圾邮件,但当我使用' leandro@xxxxx.com'它去纠正收件箱(而不是垃圾邮件),有人知道为什么???

非常感谢!

1 个答案:

答案 0 :(得分:0)

邮件服务器有很多规则来对抗/检测垃圾邮件 - 所以你要遵守一个或多个规则。

open mail relay获取邮件(当邮件地址与邮件来自的服务器不匹配时,你正在做的事情)非常好地表明了垃圾邮件。