3

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("john@example.com", "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...

Alex
  • 34,581
  • 26
  • 91
  • 135

1 Answers1

3

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
  • 339,232
  • 124
  • 596
  • 636
  • Yeah, I was able to send it from server's client. I'm installing telnet right now... – Alex Apr 07 '10 at 16:48
  • You are right. Connect failed. But even after turning off my anti virus and firewall, it still can't connect. – Alex Apr 07 '10 at 16:50
  • 1
    @Alex: From here you should post on serverfault.com, but you can see that it's not code related though. – Brian R. Bondy Apr 07 '10 at 16:54