为什么我的邮件在通过Mvc.Mailer发送时被标记为垃圾邮件?

时间:2014-01-10 15:40:00

标签: email asp.net-mvc-4 spam nuget-package

我正在使用Nuget Package Mvc.Mailer向我的客户发送电子邮件。我跟着this guide,我遇到了一个非常讨厌的事情。我发送的电子邮件总是发送到垃圾邮件。这是我的代码的样子:

UserMailer:

public virtual MvcMailMessage Authenticatie(User user, string email)
    {
        ViewBag.User = user;
        ViewBag.Email = email;
        return Populate(x =>
        {
            x.Subject = "Your registration at Example";
            x.ViewName = "Registration";
            x.IsBodyHtml = true;
            x.From = "Name <noreply@example.com>";
            x.To.Add(email);
        });
    }

Registration.cshtml:

using Mvc.Mailer

<div>
    <p style="display: none">Stuff in my email</p>
<h1 style="background: #e68425; text-align: center; color: white; margin: 0px; padding: 10px;">
    A bunch of HTML
</h1>

<div style="background: #cf7721; text-align: center; padding: 10px;">
    <h3 style="margin: 0px;"><a href="@Url.Abs(Url.Action("ALink", "Administration", new { login = @ViewBag.User.Login, h = @ViewBag.User.Activation} ))">Activate account</a></h3>
</div>

<div>
    <p>Dear client,</p>

    <p>
        Thanks for bla bla bla... And more stuff.
    </p>
    <table>
        <tr>
            <td>Login:</td>
            <td>@ViewBag.User.Login</td>
        </tr>
        <tr>
            <td>Activatiecode:</td>
            <td>@ViewBag.User.Activation</td>
        </tr>
    </table>
</div>

的Web.config:

<mailSettings>
  <!-- Method#1: Configure smtp server credentials -->
  <smtp from="Example &lt;noreply@@example.com&gt;">
    <network enableSsl="false" host="mail.@example.com" port="25" userName="noreply@example.com" password="xxx" />
  </smtp>

</mailSettings>

我们尝试了什么

  1. 使用SmtpClient以标准方式发送我们的电子邮件。这封邮件没有发送垃圾邮件。
  2. 设置x.From更好的名字。
  3. 不同的内容类型
  4. x.IsBodyHtml = true
  5. 从我们的电子邮件客户端(同一地址)发送电子邮件。这封邮件没有发送垃圾邮件。
  6. 问题

    1. 过度使用html可以过滤我们的电子邮件吗?
    2. 以前是否有人使用此Nuget包遇到此问题?
    3. 如何阻止我的电子邮件发送垃圾邮件?
    4. 最重要的是:他们为什么要发送垃圾邮件?

1 个答案:

答案 0 :(得分:0)

尝试检查模板中的所有超链接。在我的一个Url.Action中,它只是“电子邮件”这个词,因为它变成了垃圾。

相关问题