tags:

views:

130

answers:

1

I set up my hMailServer on my windows 2008 machine, and I'm trying to send emails.

When I do it with C#

MailMessage message = new MailMessage();
message.From = new MailAddress(from, "John");
message.To.Add(new MailAddress(to));
message.Subject = subject;
message.Body = body;
SmtpClient client = new SmtpClient("mail.example.com");
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
client.Send(message);

But when I try to send emails with a windows live email client, it gives me an error

The connection to the server has failed

All the settings are exactly the same. I tried several email clients, but it doesn't work. It never happened to me before. I just moved from one machine to another, and got this problem.

I can receive mail in the client though...

+2  A: 

Try to telnet to port 25, can it connect?

Open up command prompt:

telnet mail.example.com 25

If it cannot connect (which is what I expect) then you have a problem that is not code related but firewall related. (Or perhaps you're trying to connect to the wrong port if they're running SMTP on a non standard port)

Brian R. Bondy
Yeah, I was able to send it from server's client. I'm installing telnet right now...
Alex
You are right. Connect failed. But even after turning off my anti virus and firewall, it still can't connect.
Alex
@Alex: From here you should post on serverfault.com, but you can see that it's not code related though.
Brian R. Bondy