This is a guest post by Albin Sunnanbo introducing a great hack to work with mails in test environments.
If you have a .NET application that sends emails, this is probably something for you.
PickupMailViewer is a simple web viewer for emails saved by the
specifiedPickupDirectory SMTP setting in a .NET application.
Download the source, publish to your test server, configure pickup directory and you should be up and running within five minutes.
Outgoing Emails in Test Environments
In your test environment will typically not send real emails, but rather use the specifiedPickupDirectory delivery method for your SMTP-settings in
web.config. This puts all outgoing emails as *.eml files in the file system instead of sending real emails.
IMHO that is the way to go regarding emails in your test environment.
However, there is one drawback, the emails gets dropped in a folder somewhere on your test server. Typically in a location that nobody looks at regularly. In my case I first have to connect a VPN, then open a remote desktop connection to our server, open the folder and copy the desired file back to my own computer (no eml viewer, a.k.a. Outlook, on the test server) and finally open it in Outlook.
Even worse for our testers that don’t even have permissions to login on the test machine. They have to ask a developer to get their emails out of the test system. As you can imagine this only happens when it is absolutely necessary.
$(this) in jQuery callbacks? I’ve used them extensively, but never really paid attention to them until after I wrote the posts on what
this is handled in jQuery and how
$(this) is bound to the current element in jQuery event handler callbacks. The findings were not surprising, but rather show that jQuery is a well designed library.
The findings are simple:
this is a reference to the html DOM element that is the source of the event.
$(this) is a jQuery wrapper around that element that enables usage of jQuery methods.
- jQuery calls the callback using
apply() to bind
- Calling jQuery a second time (which is a mistake) on the result of
$(this) returns an new jQuery object based on the same selector as the first one.
Let’s a have a look at how jQuery handles those cases internally.
What’s the best way to name a css class:
bold-text? Is there any difference between MVC’s
TextBoxFor? Or between a
DetailedRowText property and
For all the cases, there is a difference. The first one is naming by purpose and the other naming by effect, or what it actually does. Even though the methods/properties do exactly the same thing, there’s a huge difference in the coupling they imply. When named by effect, the name is a promise to the caller on exactly what will be done. It is safe to use it in different circumstances, trusting that it will always do what the name implies. When a method is named by purpose there’s no guarantee on exactly what it will do, there’s instead a promise that it will adopt it’s behaviour as needed.
Both naming by purpose and naming by effect have their uses, but they shouldn’t be confused. The choice between them should always be deliberate and not accidental.
Let’s look closer at the examples listed above.
There’s more to
More on Methods
Last time I finished with a code example with a method that allowed me to receive payments and show my current cash level. In this post I’ll add the same function as a method to another object.
Coming from C#/C++/Java, the usage of the
In C# (and C++ and Java) the
My first assumption was that inside a method the
this keyword would refer to the current object. I was surprised when things didn’t behave as I expected, but it wasn’t