本文介绍了发送邮件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("[email protected]");
    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);

推荐答案

<system.net>
    <mailSettings>
      <smtp from="[email protected]">
        <network defaultCredentials="false" host="mail.domain.com" port="587" userName="[email protected]" password="pass"/>
      </smtp>
    </mailSettings>
  </system.net>


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


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



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

08-23 23:54