0

i am creating an email client that sends e-mail address from server ip instead of SMTP , i wrote the following code:

SmtpClient server = new SmtpClient();
server.Host= "50.23.128.66";
server.Port = 25;
server.Send("from@yahoo.com", "to@yahoo.com", "hi", "hope it works");

but when i run it, i get that error:

Unhandled Exception: System.Net.Mail.SmtpException: Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 50.23.128.66 (50.23.128.66:25), connect error 10061

i actually think that port is wrong . * By the way i am using Windows Server 2008 *

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
R.Vector
  • 1,669
  • 9
  • 33
  • 41
  • Is this your smtp server? Can you verify it works via outlook or another mail program? – leppie Jan 16 '12 at 05:35
  • So, what's the question? Your SMTP server information is incorrect. Check with your ISP to get the correct information. – Cody Gray - on strike Jan 16 '12 at 05:35
  • i actually don`t know the SMTP address , i am just using the IP address instead of SMTP Address . – R.Vector Jan 16 '12 at 05:40
  • As an alternative to using the standard `System.Net.Mail.SmtpClient` class (and assuming your firewall if configured to play nice) you could possibly use the [DnSmtp client](http://www.google.com/url?sa=t&rct=j&q=dnsmtp&source=web&cd=1&ved=0CB4QFjAA&url=http%3A%2F%2Fdnsmtp.codeplex.com%2F&ei=d7kTT42TLczq0QHshK3xDg&usg=AFQjCNHyYLcWNHPyUtiPdQb6_2aHcXtl9Q) it embeds the typical SMTP server *magic* for you so you don't have to have one to use it. – M.Babcock Jan 16 '12 at 05:46

2 Answers2

2

I think "connect error 10061" is the same as errno == ECONNREFUSED on a POSIX platform, which means the connection did not succeed, probably because the host you tried to connect to isn't running any sort of server on port 25.

Kyle Jones
  • 5,492
  • 1
  • 21
  • 30
2

According to this SMTP Server Test the server is not open to receiving connections on port 25:

No connection could be made because the target machine actively refused it 50.23.128.66:25

It's possible the server uses some form of encryption, and you will have to connect on one of the "secure" SMTP ports.

Are you sure it's an SMTP server, and not an IMAP server or the like?

ta.speot.is
  • 26,914
  • 8
  • 68
  • 96