如何在Vista上设置smtp,以便我可以使用System.Net.Mail? [英] How do I set up smtp on Vista so I can use System.Net.Mail?

查看:135
本文介绍了如何在Vista上设置smtp,以便我可以使用System.Net.Mail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我所了解的Vista中,IIS中没有SMTP服务器。我正在开展一个需要我发送电子邮件的项目。我想在我的开发框上运行Vista Ultimate开始一些简单的原型。我没有连接到一个公司网络,我只能使用一个交换服务器的某个地方。



我意识到有几个我可以安装的smtp服务器,我不知道一旦我安装一个做什么。我知道如何编写代码发送电子邮件,但我不知道使用smtp服务器需要做什么样的配置。



我喜欢是一个清晰的描述,一旦我得到一个smtp服务器安装在我的Vista盒子上。



谢谢!



更新:我下载了这个smtp服务器: http://softstack.com/freesmtp.html



这是我的代码看起来像:

  class Program 
{
static void Main(string [] args)
{
MailMessage message = new MailMessage();
message.From = new MailAddress(tad@myconsoleapp.com);
message.To.Add(new MailAddress(terry.donaghe@gmail.com));
//message.To.Add(new MailAddress(recipient3@foo.bar.com));
//message.CC.Add(new MailAddress(carboncopy@foo.bar.com));
message.Subject =这是我的主题;
message.Body =这是内容;
SmtpClient client = new SmtpClient(localhost);
client.Send(message);
Console.ReadLine();
}
}

当我有这个smtp服务器运行,我执行我的控制台应用程序,它在client.send行上。 smtp服务器如下所示:



http:// screencast.com/t/2B7jv0bE14



一段时间后,client.send超时。





谢谢!

解决方案

如您所知,SMTP不再随Vista一起提供(这是我对Vista最大的投诉之一)。你已经知道有很多选择,如果你发现一个很好的免费的一个链接到它。您如何配置它将会取决于您安装的服务器。



我玩了一些试用smtp服务器,所有我使用的都开始监听标准SMTP端口在环回IP地址上。我相信这是默认的MailSettings,不需要任何更改。



我不再有任何SMTP服务器,并且正在使用提取目录模式。这将导致邮件库输出一个文件,然后我可以检查。



要配置此文件,请在配置文件中使用以下内容:

 < system.net> 
< mailSettings>
< smtp deliveryMethod =SpecifiedPickupDirectory>
< specifiedPickupDirectory
pickupDirectoryLocation =c:\maildrop/>
< / smtp>
< / mailSettings>
< /system.net>

如果要配置它连接到本地主机上的端口25,您将为SMTP部分:

 < smtp deliveryMethod =Network> 
< network defaultCredentials =truehost =localhostport =25/>
< / smtp>



编辑



特里问了一个好问题关于使用放置位置。我只用它来进行测试,因为我们的生产服务器有一个我连接的SMTP服务器,并通过电子邮件发送;然而,一些SMTP服务器可以被配置为观看一个目录,并且会接收并发送任何东西。



我不认为这个功能只能被使用用于测试,但它的效果很好。生成的文件可以在各种邮件客户端中打开,以便您可以看到它们如何呈现。我相信他们的.eml文件,但我不记得了。


From what I understand there is no SMTP server in IIS on Vista. I am working on a project which will require me to send email. I'd like to start with some simple prototypes on my development box which is running Vista Ultimate. I'm not connected to a corporate network where I can just use an exchange server someplace.

I realize that there are several smtp servers that I can install, but I'm not sure what to do once I install one. I know how to write the code to send the email, but I don't know what kind of configuration needs to be done to use the smtp server.

What I'd like is a clear description of what to do once I get an smtp server installed on my Vista box.

Thanks!

UPDATE: I downloaded this smtp server: http://softstack.com/freesmtp.html

Here's what my code looks like:

class Program
{
    static void Main(string[] args)
    {
        MailMessage message = new MailMessage();    
        message.From = new MailAddress("tad@myconsoleapp.com");    
        message.To.Add(new MailAddress("terry.donaghe@gmail.com"));               
        //message.To.Add(new MailAddress("recipient3@foo.bar.com"));    
        //message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));    
        message.Subject = "This is my subject";    
        message.Body = "This is the content";    
        SmtpClient client = new SmtpClient("localhost");    
        client.Send(message);    
        Console.ReadLine();     
    }
}

When I have this smtp server running and I execute my console app, it hands on the client.send line. The smtp server looks like this:

http://screencast.com/t/2B7jv0bE14

After a while the client.send times out.

Any ideas what's going wrong now?

Thanks!

解决方案

As you know SMTP no longer ships with Vista (Which is one of my biggest complaints about Vista). As you already know there are many options out there, and if you found a good free one post a link to it. How you configure it will probally depend on the server you install.

I played around with some trial smtp servers, and all the ones I used started listening on the standard SMTP ports on the loopback IP Address. I believe this is the default MailSettings, and shouldn't require any changes.

I no longer have any SMTP server and am using the Pickup Directory mode. This causes the mail library to output a file which I can then inspect.

To configure this use the following in your config file:

<system.net>
    <mailSettings>
        <smtp deliveryMethod="SpecifiedPickupDirectory">
            <specifiedPickupDirectory
              pickupDirectoryLocation="c:\maildrop"/>
        </smtp>
    </mailSettings>
</system.net>

If you want to configure it to connect to port 25 on your local host you would this for the SMTP section:

<smtp deliveryMethod="Network">
   <network defaultCredentials="true" host="localhost" port="25"/>
</smtp>

Edit

Terry asked a good question about using the drop location. I only use this for testing, as our production server has an SMTP server which I connect to, and send the email through; however, some SMTP servers can be configured to watch a directory and will pick up and mail anything in there.

I don't think this feature was meant to be used only for testing but it works nicely. The files that get generated can be opened in various mail clients so you can see how they would render them. I belive they .eml files but I can't remember.

这篇关于如何在Vista上设置smtp,以便我可以使用System.Net.Mail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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