如何使用ActionMailer.Net发送电子邮件时设置EnableSsl = True?

时间:2011-06-04 15:56:31

标签: model-view-controller smtp actionmailer

我在我的MVC网站上使用ActionMailer.Net发送电子邮件,我想从gmail发送,但是gmail需要EnableSsl = True才能发送,但我不知道在ActionMailer.net中我可以配置哪里此

1 个答案:

答案 0 :(得分:3)

您必须将web.config文件编辑为以下内容:

<system.net>
  <mailSettings>
    <!-- Method#1: Configure smtp server credentials -->
    <smtp from="some-email@gmail.com">
      <network enableSsl="true" host="smtp.gmail.com" port="587" userName="some-email@gmail.com" password="valid-password" />
    </smtp>
  </mailSettings>
</system.net>

参考:

http://www.hanselman.com/blog/NuGetPackageOfTheWeek2MvcMailerSendsMailsWithASPNETMVCRazorViewsAndScaffolding.aspx\