views:

4473

answers:

5

Hi,

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("[email protected]");    
        message.To.Add(new MailAddress("[email protected]"));               
        //message.To.Add(new MailAddress("[email protected]"));    
        //message.CC.Add(new MailAddress("[email protected]"));    
        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!

+7  A: 

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.

JoshBerke
So this technique doesn't send email, right? Is it just used for testing?
Terry Donaghe
thanks:-) I'm still loving this solution
JoshBerke
A: 

You can find a very basic SMTP server coded in C# .NET in stickymailserver:

Sticky Mail Server is a low-interaction SMTP Honeypot designed to emulate a open SMTP relay. It captures and logs probe messages and mass mailings and saves them for later analysis.

gimel
A: 

You could use an externally hosted SMTP server. I have found that a lot of email system will block access if the originating SMTP server is behind a dynamic IP address (like most residential systems).

I had to do this recently.

 SmtpClient smtp = new SmtpClient("smtp.myserver.com");
 smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
 smtp.Credentials = new System.Net.NetworkCredential("Username", "Password");

Using the "SendCompleted" event, you can send the email in the background without delaying the application.

Chris Thompson
A: 

@JoshBerke

I've tried using the below option but receive "Cannot get IIS pickup directory". I know I am pointing to an existing directory, are there permissions I need to set up on the directory?

<smtp deliveryMethod="SpecifiedPickupDirectory">
     <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop"/>
</smtp>
gangelo
A: 

I have gotten angry . why doesnt any one of these works? you tell me.

mehdi