MVC 4 Email.Send错误

时间:2014-03-17 14:12:15

标签: asp.net-mvc-4 email postal

我正在使用Postal向新注册用户发送确认电子邮件。但它在遇到email.send();时会陷入困境。这是我的控制器代码:

public ActionResult Register(RegisterModel model)
    {
        if (ModelState.IsValid)
        {
            // Attempt to register the user
            try
            {
                string confirmationToken =  
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, 
                                new { model.Email}, true);

                dynamic email = new Email("RegEmail");
                email.To = model.Email;
                email.UserName = model.UserName;
                email.ConfirmationToken = confirmationToken;
                email.HostLocation = Request.Url.Host + ':' + Request.Url.Port;

                email.Send();

                return RedirectToAction("RegisterStepTwo", "Account");
                //return RedirectToAction("Index", "Festival");
            }
            catch (MembershipCreateUserException e)
            {
                ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

有谁知道这个问题?

0 个答案:

没有答案