Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test sending emails from asp.net on development machine?

How do I accomplish this? The SMTP class throws error on dev machine about not finding an SMTP server. Is there a way to test sending emails on development machine?

like image 725
Shawn Mclean Avatar asked Oct 22 '10 15:10

Shawn Mclean


People also ask

How do I use smtp4dev?

Navigate to System administration > Setup > Email parameters and click the Configuration tab, then set Batch email provider to SMTP. Next, click the SMTP settings tab. Here we need to enter parameters for smtp4dev as follows: Set Outgoing mail server to localhost and SMTP port number to 25.


2 Answers

Shawn,

Straight from my web.config:

  <smtp deliveryMethod="SpecifiedPickupDirectory">
    <network host="ignored" />
    <specifiedPickupDirectory pickupDirectoryLocation="c:\email_c#" />
  </smtp>

this works fine insofar as being able to review the 'emails' that get saved into the pickupDirectoryLocation directory.

Give it a try...

like image 93
jim tollan Avatar answered Oct 16 '22 11:10

jim tollan


You can dump the files on disk, by configuring System.Net.Mail.SmtpClient to use a deliveryMethod of type SpecifiedPickupDirectory, I found an example on SO

like image 35
Marijn Avatar answered Oct 16 '22 09:10

Marijn