Testing SMTP with .net

后端 未结 17 1246
[愿得一人]
[愿得一人] 2020-12-04 09:54

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 w

相关标签:
17条回答
  • 2020-12-04 10:48

    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.

    0 讨论(0)
  • 2020-12-04 10:48

    there's also my very own http://ssfd.codeplex.com/ which is an open source SMTP emulator. Receives e-mail and drops them in a folder which can be accessed by a task icon

    0 讨论(0)
  • 2020-12-04 10:50

    For .NET guys out there. Keeping it simple.

    We were looking into this and then one of the developers remembered about a the config setting that allows you to override how the emails are sent.

    This will create a file per email and leave it alone.

    <system.net>
        <mailSettings>
          <smtp deliveryMethod="SpecifiedPickupDirectory">
            <specifiedPickupDirectory pickupDirectoryLocation="\\SharedFolder\MailDrop\" />
          </smtp>      
        </mailSettings>
      </system.net>
    
    0 讨论(0)
  • 2020-12-04 10:52

    As noted by Sean Carpenter, Papercut is a powerful solution for local development. If you also run a staging or testing server, however, mailtrap.io may be a simpler solution overall, because you can use the same approach for your dev and staging environments.

    0 讨论(0)
  • 2020-12-04 10:53

    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

    0 讨论(0)
  • 2020-12-04 10:54

    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.

    0 讨论(0)
提交回复
热议问题