发送邮件ASP.net MVC.麻烦 [英] Send Mail ASP.net MVC. Trouble

查看:67
本文介绍了发送邮件ASP.net MVC.麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我发送邮件的代码(测试代码):

This is my code to send mail (test code):

                //sending mail
var message = new System.Net.Mail.MailMessage();
    message.From = new MailAddress("J2v@gmail.com");
    message.To.Add(model.Mailag);
    message.Subject = "Valdation d'inscription";
    message.Body = "Votre inscription a été valide voici vos cordonne de conexion ID user : "+model.Idag+" Password : "+user.password;
    var client = new  System.Net.Mail.SmtpClient
    {
        Host = "smtp.gmail.com",
        Port = 587,
        EnableSsl = true,
        UseDefaultCredentials = false,
        Credentials = new NetworkCredential("", "")
    };
client.Send(message);


当我尝试它时,出现以下错误:SMTP server require secured connexion or you are not connected. Server response was :5.5.1 Authentication Required.在此行上client.Send(message);


When i try it i got this error : SMTP server require secured connexion or you are not connected. Server response was :5.5.1 Authentication Required. On this line client.Send(message);

推荐答案

我认为此邮件设置应该可以帮助您:
defaultCredentials ="false"
I think this mail setting should help you :
defaultCredentials="false"
<system.net>
    <mailSettings>
      <smtp from="info@domain.com">
        <network defaultCredentials="false" host="mail.domain.com" port="587" userName="info@.domain.com" password="pass"/>
      </smtp>
    </mailSettings>
  </system.net>


并检查以下内容:
https://github.com/smsohan/MvcMailer [


And also check this:
https://github.com/smsohan/MvcMailer[^]



请参考以下链接:
宣布MvcMailer-使用ASP.NET MVC视图发送电子邮件 [ ^ ]
http://drfonz.wordpress.com/2011/03/22/asp-net-mvc-3-mailing-views-successfully-deploying-mvcmailer-in-your-projects/ [ http://论坛. asp.net/t/1797516.aspx/1?Asp+Net+MVC+3+Send+Razor+contact+form+to+email+ [
Hi,
Refer the links below:
Announcing MvcMailer - Send Emails Using ASP.NET MVC View[^]
http://drfonz.wordpress.com/2011/03/22/asp-net-mvc-3-mailing-views-successfully-deploying-mvcmailer-in-your-projects/[^]
http://forums.asp.net/t/1797516.aspx/1?Asp+Net+MVC+3+Send+Razor+contact+form+to+email+[^]



--Amit


这篇关于发送邮件ASP.net MVC.麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆