asp.net mvc 4 Send form from site to email

后端 未结 2 2012
别那么骄傲
别那么骄傲 2021-02-10 10:33

I have feedback form on my mvc site, it looks like

\"enter

and I need to send my

相关标签:
2条回答
  • 2021-02-10 10:47

    Change

    catch (Exception)
        {
            return false;
        }
    

    To

    catch (Exception ex)
        {
    // breakpoint here, inspect ex
            return false;
        }
    
    0 讨论(0)
  • 2021-02-10 10:54

    I have copy-pasted your code and got it to work, with some small modifications:

    1. I did not set the Credentials property
    2. I modified the template to remove the @Value attribute:

      @Html.TextBoxFor(model => model.Name) @Html.TextBoxFor(model => model.Email) @Html.TextBoxFor(model => model.Phone)

    These are the only changes I made and I got your application to work. This leads me to believe that there must be something wrong in your SMTP client's configuration. Can you examine the exception that is thrown by client.Send(msg);? I expect it will say something about invalid network credentials or something like that.

    0 讨论(0)
提交回复
热议问题