views:

884

answers:

4

Hi;

I am looking for a free test smptp server which can save emails in to files for my development tests. Since my development environment is windows I prefer test email server to run on windows but I can consider to install any other linux based alternatives.

+5  A: 

-- Edit:

This advice only valid if you're using .NET

Check this out. If you set it appropriately, it will just store your emails on disk :)

SmtpClient client = ...;
client.PickupDirectoryLocation = @"c:\foo\emails\"; //"
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;

-- Edit

Just in case some people don't get it, this means you don't need another SMTP server for test/dev, you just set the variable appropriately.

-- Edit

For completeness, as marc_s shows below, you can set this in configs nicely via:

<system.net>  
   <mailSettings>  
      <smtp deliveryMethod="SpecifiedPickupDirectory">  
         <specifiedPickupDirectory 
             pickupDirectoryLocation="c:\foo\emails\" />  
      </smtp>  
   </mailSettings>  
</system.net>
Noon Silk
That of course assumes that the OP is using C# to write his software.
Martin v. Löwis
Yes. You make a fair point Martin, I assumed he was using .NET, but now noticed it's not specified in the original post. My mistake for being in a '.NET' state of mind :)
Noon Silk
You can configure this without changing any code in the application configuration file: `confguration\system.net\mailSettings\smtp` element.
Thorarin
Thorarin: Yes, 'marc_s' shows how, below. I don't feel right editing his answer into mine though.
Noon Silk
+4  A: 

The Python smtpd module has a DebuggingServer which prints all messages to stdout. If you redirect them to a file, you should be done.

Martin v. Löwis
I had python already installed so it took few minutes for me to look for an example then implement the debugging server. I have a small problem with displaying UTF-8 encoded emails. When I try sending emails via gmail, there is no problem with the UTF-8 encoded messages, however the smtpd module of python does not print non-ascii characters correctly. Do you have any suggestions on this issue?
Tolga
In general e-mails need to be encoded using quoted-printable or base64 encoding and transferred only in 7-bit ASCII encoding (look for MIME RFC on Google). While some SMTP server extensions allow sending 8-bit e-mails it is not something you should count on.
Filip Navara
The official way in Python to process MIME messages is the email package. However, doing that might be overkill - so I rather recommend to write all messages in an mbox file (either by directly appending it, or through the mailbox module), and then open the module in Thunderbird.
Martin v. Löwis
+3  A: 

There are a few:

Or you can also set it up in your web.config to just store the e-mails in the file system (the config way of what "silky" has proposed in code):

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

Marc

marc_s
antix standalone installation was exact solution for my problem. This one is better since I had problem with python debugging server which is not suitable for UTF-8 encoded messages.
Tolga
@tolga: great - glad I could help!
marc_s
+1  A: 

Below are the links i found

Use depending on the Language and Platform of your choice.

There is also an earlier post for .NET http://stackoverflow.com/questions/550887/testing-smtp-with-net