我正在使用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 <noreply@@example.com>">
<network enableSsl="false" host="mail.@example.com" port="25" userName="noreply@example.com" password="xxx" />
</smtp>
</mailSettings>
我们尝试了什么
x.IsBodyHtml = true
问题
答案 0 :(得分:0)
尝试检查模板中的所有超链接。在我的一个Url.Action中,它只是“电子邮件”这个词,因为它变成了垃圾。