On several occasions, when working with SMTP email in .NET, I’ve wasted a few hours for a variety of reasons relating to firewalls, virus scanners, relay only from domain addresses and plain stupidity (pointing at the wrong server for instance), to name just a few.
Recently, a colleague fell victim to one such annoying problem. We both went through the list of usual suspects, trying everything we could think of, until we reached the ‘this is crazy!” point.
The Solution: If you’re running a later version of Mcaffee virus protection, you might want to turn off the default behaviour of blocking any outbound traffic port 25!
I’m tempted to mention the maxim of Sherlock Holmes:
“How often have I said to you that when you have eliminated the impossible,
whatever remains, however improbable, must be the truth” – The Sign of The Four, Sir Arthur Conan Doyle.
There is a useful FAQ for the 2.0 .NET Framework’s System.Net.Mail namespace at System.Net.Mail covering a range of common and advanced scenarios (and a corresponding one for 1.1 here).