July 04, 2003
|
SMTP and email in ASP.NET
|
1945 hit(s)
Finally got around to posting an FAQ on issues to do with configuring and sending email messages from ASP.NET.
On first blush, sending email from a Web app is deceptively simple; it takes about 10 lines of code. Most of the articles and other documentation I've seen about sending email stop right there. Few of them go into any details about how to configure the all-important SMTP server that does all the heavy lifting; generally, this is dismissed with some general hand-waving about "you must have an SMTP server available and configured properly." Yet that's a source of many of the problems.
Moreover, there are many ways that sending email can go wrong, and I personally seem to have experienced just about every one of them. Because ASP.NET email classes are really just wrappers on a Windows COM object (CDO), the error messages you get when things go wrong are pretty unhelpful, along the lines of "Could not access 'CDO.Message' object." Yeah, thanks, that helps a lot. On top of that, you might have been "successful" in sending a message -- that is, it might have made the first hop to your local email server ok -- but then the recipient's email server might have a problem with your email, and you won't know that till later, when the email bounces or something.
Anyway, that's done for now. At some point I'll need to take the FAQ information and find a way to slip it into the documentation at work, although technically I don't own the mail stuff.