在web.config中設置電子郵件詳細信息 - 但沒有發送電子郵件!在appsettings中設置電子郵件設置web.config
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="smtpServer" value="smtp.live.com" />
<add key="EnableSsl" value = "true"/>
<add key="smtpPort" value="587" />
<add key="smtpUser" value="[email protected]" />
<add key="smtpPass" value="mypasswordgoeshere" />
<add key="adminEmail" value="[email protected]" />
</appSettings>
我使用下面的類
這帳戶控制:
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
Membership.CreateUser(model.UserName,
model.Password, model.Email, null, null,
true, null, out createStatus);
if (createStatus ==
MembershipCreateStatus.Success)
{
// Send welcome email
MailClient.SendWelcome(model.Email);
FormsAuthentication.SetAuthCookie(
model.UserName,
false /* createPersistentCookie */);
return RedirectToAction("create", "Customer");
}
else
{
ModelState.AddModelError("",
ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed,
// redisplay form
return View(model);
}
都在爲在enableSsl web.config中正確應用程序的設置? 歡迎任何建議
你有什麼會讀這些appSettings並將它們設置在你的SMTP對象? – 2012-04-05 04:04:27
隨着你添加的代碼,你會得到一個異常?發生什麼事?我沒有看到你在代碼中設置了啓用SSL的位置,也許我忽略了它。您需要在代碼中使用Client.EnableSsl = bool.parse(ConfigurationManager.AppSettings [「EnableSsl」]) – 2012-04-05 04:16:35
代碼:Client.EnableSsl = bool.parse(ConfigurationManager.AppSettings [「EnableSsl」])你會把它放在哪裏類 – 2012-04-05 04:48:06