Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing SMTP with .net

Tags:

.net

testing

smtp

I need to configure a SMTP server for testing my website which sends emails (for registration confirmation etc).

I dont actually want the email to be sent, I just want to make sure that my code is correct. So I want to be able to check that the email is placed in a queue folder for example.

Can anybody recommend a SMTP server which is easy to configure?

like image 437
iasksillyquestions Avatar asked Feb 15 '09 13:02

iasksillyquestions


3 Answers

There's also Papercut which is an SMTP server which will receive messages but not deliver them anywhere (allowing you to make sure they are being sent correctly). The received messages are visible in a small GUI and are also written to a directory.

like image 199
Sean Carpenter Avatar answered Nov 07 '22 20:11

Sean Carpenter


In .NET, SmtpClient can be configured to send email by placing it in a pickup directory.

The default constructor of SmtpClient takes its settings from app.config, so for a test environment we can configure it as follows.

<configuration>
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="specifiedPickupDirectory">
                <specifiedPickupDirectory pickupDirectoryLocation="path to a directory" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

MSDN reference - app.config mailSettings element http://msdn.microsoft.com/en-us/library/w355a94k.aspx

like image 33
Lachlan Roche Avatar answered Nov 07 '22 21:11

Lachlan Roche


The smtp4dev project is another dummy SMTP server. I like it because it has a nice, simple UI that logs the messages and lets you view the contents of recent messages. Written in C# with an MSI installer. Source code is available.

like image 21
Don Kirkby Avatar answered Nov 07 '22 21:11

Don Kirkby