Since you have output the message into a label and decided to insert a line break
<br>
you might not be seeing the interesting part of the error message. That is the part added after the line break by
ex.Message
.
I'll make an attempt at producing some
Liquid Nitrogen[
^] and throw you some educated guesses:
- If there is no SMTP server running on the machine hosting your website the
SmptClient
will not be able to connect to the SMPT server on localhost
(127.0.0.1). - There may be a SMTP server running on your machine, but it's not listening to the well known SMTP port 25, but rather some other more esoteric port number.
- The SMTP server on your machine requires the sender of an email to authenticate themselves. So you'd have to send some
NetworkCredentials
along with your request.
To make sure that there is a SMTP server running on your server open up a command prompt window and do this:
c:\ telnet localhost 25
followed by enter.
If you have a SMPT server listening on port 25 it will connect and you can start issueing SMTP commands from the prompt to further debug your issue. The SMTP protocol is very simplistic and you can easily google a source for yourself.
If you can't connect there either is no SMPT server on your machine or it listens to a different port. This should be an issue of the administrator of that server, so kindly talk to that person and ask for help.
Best Regards,
—MRB