问题描述
我正在尝试在 IIS 上设置 SMTP 服务器以发送邮件.SMTP 服务器旨在供 C# 中的 ASP.NET 代码使用.
I am trying to setup SMTP server on IIS for sending mails. The SMTP server is intended to be used by the ASP.NET code in C#.
我之前使用的是 gmail smtp,其中我将 smtp.gmail.com 作为主机提供了安全端口和我的 gmail uid/pwd.那工作得很好.这是用于执行此操作的代码.
I was previously using gmail smtp wherein i provided the smtp.gmail.com as host with secure port and my gmail uid/pwd. That worked fine. Here is the code used to do that.
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = false;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.Credentials = new NetworkCredential(uname,pwd);
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
现在我计划在 IIS 上使用 localhost SMTP 服务器,我应该为参数 UseDefaultCredentials 和 Credentials 提供什么值.我将分配 false 给 EnableSsl,因为它通过端口 25.
Now i am planning to use the localhost SMTP server on IIS, what values should i be giving for the parameters UseDefaultCredentials and Credentials. I will be assigning false to EnableSsl as it's over port 25.
另外,最简单的 SMTP 虚拟服务器配置可能是什么.
Also, what could be the most simple SMTP virtual server configuration.
推荐答案
我认为在 localhost 中你可以使用:
I think in localhost you can use :
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = true;
smtpClient.Send(mailMessage);
这篇关于使用 localhost SMTP 发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!