Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending test emails in development without spam or rejection issues

Tags:

.net

windows

I run my development environment in a VM and need to test the delivery and appearance of emails from my applications. The problem is when my SMTP server starts delivering a lot of mail to my corporate email account, the server is soon rejected as a source of spam. Of course, the major Internet email providers will also never accept email from such a server.

One solution with a problem: I've delivered to a to a file folder using the .NET SpecifiedPickupDirectory option and open in outlook express, but the problem is that VALID images always display as broken images.

like image 470
Micah B. Avatar asked Feb 28 '23 06:02

Micah B.


2 Answers

Your answer: Papercut, an open source pseudo-SMTP test server. This is the ultimate dev email testing app that is a must have.

like image 142
Jaxidian Avatar answered Apr 28 '23 06:04

Jaxidian


You could do quite a lot of your email scenarios using unit tests and a mock mailer implementation. For example, you can create an interface for and a wrapper around the SmtpClient class. This wrapper should implement the interface. Use dependency injection to provide the dependent SmtpWrapper class (as the interface) to the class that uses it. In your unit tests, you can supply a mock instance of the interface to the class under test and ensure that it is correctly sending the messages that you expect to the recipients that you expect given the set up of the test.

Eventually, you will have to run some integration tests, but probably much fewer. In your integration tests you can you use your test SMTP server. Given that most of your tests are run in unit testing with your mock implementation, this might be enough to keep your corporate mail server from misidentifying your test server.

like image 34
tvanfosson Avatar answered Apr 28 '23 06:04

tvanfosson