使用本地主机的SMTP发送邮件 [英] Send mail using localhost SMTP

查看:279
本文介绍了使用本地主机的SMTP发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置SMTP服务器上IIS用于发送邮件。 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其中i提供的smtp.gmail.com作为主机安全端口和我的Gmail UID /密码。这工作得很好。这里是用来做什么的代码

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上的本地主机的SMTP服务器,什么样的​​价值观,我应该给人的参数UseDefaultCredentials和证书。我将指派假以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.

推荐答案

我觉得在本地主机可以使用:

I think in localhost you can use :

SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = true;
smtpClient.Send(mailMessage);

这篇关于使用本地主机的SMTP发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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